function EntityFieldTest::createTestEntity
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php \Drupal\KernelTests\Core\Entity\EntityFieldTest::createTestEntity()
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php \Drupal\KernelTests\Core\Entity\EntityFieldTest::createTestEntity()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php \Drupal\KernelTests\Core\Entity\EntityFieldTest::createTestEntity()
Creates a test entity.
Return value
\Drupal\Core\Entity\EntityInterface
7 calls to EntityFieldTest::createTestEntity()
- EntityFieldTest::doTestComputedProperties in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php - Executes the computed properties tests for the given entity type.
- EntityFieldTest::doTestDataStructureInterfaces in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php - Executes the data structure interfaces tests for the given entity type.
- EntityFieldTest::doTestIterator in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php - Executes the iterator tests for the given entity type.
- EntityFieldTest::doTestReadWrite in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php - Executes the read write test set for a defined entity type.
- EntityFieldTest::doTestSave in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php - Executes the save tests for the given entity type.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php, line 82
Class
- EntityFieldTest
- Tests the Entity Field API.
Namespace
Drupal\KernelTests\Core\EntityCode
protected function createTestEntity($entity_type) : EntityInterface {
$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 = $this->container
->get('entity_type.manager')
->getStorage($entity_type)
->create();
$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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.