function EntityViewControllerTest::createTestEntity

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

Return value

\Drupal\Core\Entity\EntityInterface The created entity.

File

core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php, line 132

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.