You are here

protected function NodeCacheTagsTest::createEntity in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/node/tests/src/Functional/NodeCacheTagsTest.php \Drupal\Tests\node\Functional\NodeCacheTagsTest::createEntity()

Creates the entity to be tested.

Return value

\Drupal\Core\Entity\EntityInterface The entity to be tested.

Overrides EntityCacheTagsTestBase::createEntity

File

core/modules/node/tests/src/Functional/NodeCacheTagsTest.php, line 30

Class

NodeCacheTagsTest
Tests the Node entity's cache tags.

Namespace

Drupal\Tests\node\Functional

Code

protected function createEntity() {

  // Create a "Camelids" node type.
  NodeType::create([
    'name' => 'Camelids',
    'type' => 'camelids',
  ])
    ->save();

  // Create a "Llama" node.
  $node = Node::create([
    'type' => 'camelids',
  ]);
  $node
    ->setTitle('Llama')
    ->setPublished()
    ->save();
  return $node;
}