function HtmlResponseAttachmentsTest::testRenderCachedBlock

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

Test caching of ['#attached'].

File

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

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->assertText('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->assertText('Markup from attached_rendering_block.');
    // The header should be present again.
    $this->assertSession()
        ->responseHeaderEquals('X-Test-Teapot', 'Teapot Mode Active');
}

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