function BlockContentCacheTagsTest::createEntity

Same name and namespace in other branches
  1. 9 core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php \Drupal\Tests\block_content\Functional\BlockContentCacheTagsTest::createEntity()
  2. 8.9.x core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php \Drupal\Tests\block_content\Functional\BlockContentCacheTagsTest::createEntity()
  3. 10 core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php \Drupal\Tests\block_content\Functional\BlockContentCacheTagsTest::createEntity()

Creates the entity to be tested.

Return value

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

Overrides EntityCacheTagsTestBase::createEntity

File

core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php, line 34

Class

BlockContentCacheTagsTest
Tests the Content Block entity's cache tags.

Namespace

Drupal\Tests\block_content\Functional

Code

protected function createEntity() {
  $block_content_type = BlockContentType::create([
    'id' => 'basic',
    'label' => 'basic',
    'revision' => FALSE,
  ]);
  $block_content_type->save();
  block_content_add_body_field($block_content_type->id());
  // Create a "Llama" content block.
  $block_content = BlockContent::create([
    'info' => 'Llama',
    'type' => 'basic',
    'body' => [
      'value' => 'The name "llama" was adopted by European settlers from native Peruvians.',
      'format' => 'plain_text',
    ],
  ]);
  $block_content->save();
  return $block_content;
}

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