protected function EntityFieldTest::createTestEntity

Creates a test entity.

Return value

\Drupal\Core\Entity\EntityInterface

6 calls to EntityFieldTest::createTestEntity()
EntityFieldTest::assertComputedProperties in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Executes the computed properties tests for the given entity type.
EntityFieldTest::assertDataStructureInterfaces in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Executes the data structure interfaces tests for the given entity type.
EntityFieldTest::assertIterator in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Executes the iterator tests for the given entity type.
EntityFieldTest::assertReadWrite in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Executes the read write test set for a defined entity type.
EntityFieldTest::assertSave in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Executes the save tests for the given entity type.

... See full list

File

drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php, line 62
Definition of Drupal\system\Tests\Entity\EntityFieldTest.

Class

EntityFieldTest
Tests Entity API base functionality.

Namespace

Drupal\system\Tests\Entity

Code

protected function createTestEntity($entity_type) {
  $this->entity_name = $this
    ->randomName();
  $this->entity_user = $this
    ->createUser();
  $this->entity_field_text = $this
    ->randomName();

  // Pass in the value of the name field when creating. With the user
  // field we test setting a field after creation.
  $entity = entity_create($entity_type, array());
  $entity->user_id->target_id = $this->entity_user->uid;
  $entity->name->value = $this->entity_name;

  // Set a value for the test field.
  $entity->field_test_text->value = $this->entity_field_text;
  return $entity;
}