public function HtmlResponseAttachmentsTest::testRenderCachedBlock in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php \Drupal\Tests\system\Functional\Render\HtmlResponseAttachmentsTest::testRenderCachedBlock()
- 10 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 75 
Class
- HtmlResponseAttachmentsTest
- Functional tests for HtmlResponseAttachmentsProcessor.
Namespace
Drupal\Tests\system\Functional\RenderCode
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');
}