protected function RESTTestBase::entityValues

Provides an array of suitable property values for an entity type.

Required properties differ from entity type to entity type, so we keep a minimum mapping here.

Parameters

string $entity_type: The type of the entity that should be created.

Return value

array An array of values keyed by property name.

2 calls to RESTTestBase::entityValues()
CreateTest::testCreate in drupal/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php
Tests several valid and invalid create requests on all entity types.
RESTTestBase::entityCreate in drupal/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php
Creates entity objects based on their types.

File

drupal/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php, line 159
Definition of Drupal\rest\test\RESTTestBase.

Class

RESTTestBase
Test helper class that provides a REST client method to send HTTP requests.

Namespace

Drupal\rest\Tests

Code

protected function entityValues($entity_type) {
  switch ($entity_type) {
    case 'entity_test':
      return array(
        'name' => $this
          ->randomName(),
        'user_id' => 1,
        'field_test_text' => array(
          0 => array(
            'value' => $this
              ->randomString(),
          ),
        ),
      );
    case 'node':
      return array(
        'title' => $this
          ->randomString(),
        'type' => $this
          ->randomString(),
      );
    case 'user':
      return array(
        'name' => $this
          ->randomName(),
      );
    default:
      return array();
  }
}