protected function EntityFieldTest::createTestEntity in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Entity/EntityFieldTest.php \Drupal\system\Tests\Entity\EntityFieldTest::createTestEntity()
Creates a test entity.
Return value
\Drupal\Core\Entity\EntityInterface
6 calls to EntityFieldTest::createTestEntity()
- EntityFieldTest::doTestComputedProperties in core/
modules/ system/ src/ Tests/ Entity/ EntityFieldTest.php - Executes the computed properties tests for the given entity type.
- EntityFieldTest::doTestDataStructureInterfaces in core/
modules/ system/ src/ Tests/ Entity/ EntityFieldTest.php - Executes the data structure interfaces tests for the given entity type.
- EntityFieldTest::doTestIterator in core/
modules/ system/ src/ Tests/ Entity/ EntityFieldTest.php - Executes the iterator tests for the given entity type.
- EntityFieldTest::doTestReadWrite in core/
modules/ system/ src/ Tests/ Entity/ EntityFieldTest.php - Executes the read write test set for a defined entity type.
- EntityFieldTest::doTestSave in core/
modules/ system/ src/ Tests/ Entity/ EntityFieldTest.php - Executes the save tests for the given entity type.
File
- core/
modules/ system/ src/ Tests/ Entity/ EntityFieldTest.php, line 73 - Contains \Drupal\system\Tests\Entity\EntityFieldTest.
Class
- EntityFieldTest
- Tests the Entity Field API.
Namespace
Drupal\system\Tests\EntityCode
protected function createTestEntity($entity_type) {
$this->entityName = $this
->randomMachineName();
$this->entityUser = $this
->createUser();
$this->entityFieldText = $this
->randomMachineName();
// 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);
$entity->user_id->target_id = $this->entityUser
->id();
$entity->name->value = $this->entityName;
// Set a value for the test field.
$entity->field_test_text->value = $this->entityFieldText;
return $entity;
}