function EntityViewControllerTest::createTestEntity
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php \Drupal\Tests\system\Functional\Entity\EntityViewControllerTest::createTestEntity()
- 8.9.x core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php \Drupal\Tests\system\Functional\Entity\EntityViewControllerTest::createTestEntity()
- 11.x core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php \Drupal\Tests\system\Functional\Entity\EntityViewControllerTest::createTestEntity()
Creates an entity for testing.
Parameters
string $entity_type: The entity type.
string|null $name: The entity name, or NULL to generate random name.
Return value
\Drupal\Core\Entity\EntityInterface The created entity.
3 calls to EntityViewControllerTest::createTestEntity()
- EntityViewControllerTest::setUp in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityViewControllerTest.php - EntityViewControllerTest::testEntityViewController in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityViewControllerTest.php - Tests EntityViewController.
- EntityViewControllerTest::testEntityViewControllerViewBuilder in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityViewControllerTest.php - Tests that a view builder can successfully override the view builder.
File
-
core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityViewControllerTest.php, line 134
Class
- EntityViewControllerTest
- Tests EntityViewController functionality.
Namespace
Drupal\Tests\system\Functional\EntityCode
protected function createTestEntity($entity_type, $name = NULL) {
$data = [
'bundle' => $entity_type,
'name' => $name ?? $this->randomMachineName(),
];
return $this->container
->get('entity_type.manager')
->getStorage($entity_type)
->create($data);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.