You are here

protected function EntityViewControllerTest::createTestEntity in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php \Drupal\Tests\system\Functional\Entity\EntityViewControllerTest::createTestEntity()
  2. 9 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.

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 145

Class

EntityViewControllerTest
Tests EntityViewController functionality.

Namespace

Drupal\Tests\system\Functional\Entity

Code

protected function createTestEntity($entity_type) {
  $data = [
    'bundle' => $entity_type,
    'name' => $this
      ->randomMachineName(),
  ];
  return $this->container
    ->get('entity_type.manager')
    ->getStorage($entity_type)
    ->create($data);
}