You are here

public function HtmlResponseAttachmentsTest::testRenderCachedBlock in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php \Drupal\Tests\system\Functional\Render\HtmlResponseAttachmentsTest::testRenderCachedBlock()
  2. 9 core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php \Drupal\Tests\system\Functional\Render\HtmlResponseAttachmentsTest::testRenderCachedBlock()

Tests caching of ['#attached'].

File

core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php, line 80

Class

HtmlResponseAttachmentsTest
Functional tests for HtmlResponseAttachmentsProcessor.

Namespace

Drupal\Tests\system\Functional\Render

Code

public function testRenderCachedBlock() {

  // Make sure our test block is visible.
  $this
    ->drupalPlaceBlock('attached_rendering_block', [
    'region' => 'content',
  ]);

  // Get the front page, which should now have our visible block.
  $this
    ->drupalGet('');

  // Make sure our block is visible.
  $this
    ->assertSession()
    ->pageTextContains('Markup from attached_rendering_block.');

  // Test that all our attached items are present.
  $this
    ->assertFeed();
  $this
    ->assertHead();
  $this
    ->assertSession()
    ->statusCodeEquals(418);
  $this
    ->assertTeapotHeaders();

  // Reload the page, to test caching.
  $this
    ->drupalGet('');

  // Make sure our block is visible.
  $this
    ->assertSession()
    ->pageTextContains('Markup from attached_rendering_block.');

  // The header should be present again.
  $this
    ->assertSession()
    ->responseHeaderEquals('X-Test-Teapot', 'Teapot Mode Active');
}