function NodeCacheTagsTest::createEntity

Same name and namespace in other branches
  1. 9 core/modules/node/tests/src/Functional/NodeCacheTagsTest.php \Drupal\Tests\node\Functional\NodeCacheTagsTest::createEntity()
  2. 8.9.x core/modules/node/tests/src/Functional/NodeCacheTagsTest.php \Drupal\Tests\node\Functional\NodeCacheTagsTest::createEntity()
  3. 10 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 32

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

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