protected function RESTTestBase::entityCreate

Creates entity objects based on their types.

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

\Drupal\Core\Entity\EntityInterface The new entity object.

2 calls to RESTTestBase::entityCreate()
DeleteTest::testDelete in drupal/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php
Tests several valid and invalid delete requests on all entity types.
ReadTest::testRead in drupal/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php
Tests several valid and invalid read requests on all entity types.

File

drupal/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php, line 111
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 entityCreate($entity_type) {
  switch ($entity_type) {
    case 'entity_test':
      return entity_create('entity_test', array(
        'name' => $this
          ->randomName(),
        'user_id' => 1,
      ));
    case 'node':
      return entity_create('node', array(
        'title' => $this
          ->randomString(),
      ));
    case 'user':
      return entity_create('user', array(
        'name' => $this
          ->randomName(),
      ));
    default:
      return entity_create($entity_type, array());
  }
}