protected function EntityFieldTest::createTestEntity

Creates a test entity.

Return value

\Drupal\Core\Entity\EntityInterface

5 calls to EntityFieldTest::createTestEntity()
EntityFieldTest::testComputedProperties in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Tests getting processed property values via a computed property.
EntityFieldTest::testDataStructureInterfaces in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Tests working with entity properties based upon data structure and data list interfaces.
EntityFieldTest::testIterator in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Tests iterating over properties.
EntityFieldTest::testReadWrite in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Tests reading and writing properties and field items.
EntityFieldTest::testSave in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Tries to save and load an entity again.

File

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

Class

EntityFieldTest
Tests Entity API base functionality.

Namespace

Drupal\system\Tests\Entity

Code

protected function createTestEntity() {
  $this->entity_name = $this
    ->randomName();
  $this->entity_user = $this
    ->drupalCreateUser();
  $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_test', array());
  $entity->user_id->value = $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;
}