protected function EntityViewBuilderTest::createTestEntity in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php \Drupal\KernelTests\Core\Entity\EntityViewBuilderTest::createTestEntity()
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php \Drupal\KernelTests\Core\Entity\EntityViewBuilderTest::createTestEntity()
Creates an entity for testing.
Parameters
string $entity_type: The entity type.
Return value
\Drupal\Core\Entity\EntityInterface The created entity.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityViewBuilderTest.php, line 320
Class
- EntityViewBuilderTest
- Tests the entity view builder.
Namespace
Drupal\KernelTests\Core\EntityCode
protected function createTestEntity($entity_type) {
$data = [
'bundle' => $entity_type,
'name' => $this
->randomMachineName(),
];
return $this->container
->get('entity_type.manager')
->getStorage($entity_type)
->create($data);
}