You are here

public function BlockViewBuilderTest::testBlockViewBuilderCache in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php \Drupal\Tests\block\Kernel\BlockViewBuilderTest::testBlockViewBuilderCache()

Tests block render cache handling.

File

core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php, line 127

Class

BlockViewBuilderTest
Tests the block view builder.

Namespace

Drupal\Tests\block\Kernel

Code

public function testBlockViewBuilderCache() {

  // Verify cache handling for a non-empty block.
  $this
    ->verifyRenderCacheHandling();

  // Create an empty block.
  $this->block = $this->controller
    ->create([
    'id' => 'test_block',
    'theme' => 'stark',
    'plugin' => 'test_cache',
  ]);
  $this->block
    ->save();
  \Drupal::state()
    ->set('block_test.content', NULL);

  // Verify cache handling for an empty block.
  $this
    ->verifyRenderCacheHandling();
}