You are here

public function HtmlResponseAttachmentsTest::testAttachments in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Render/HtmlResponseAttachmentsTest.php \Drupal\system\Tests\Render\HtmlResponseAttachmentsTest::testAttachments()

Test rendering of ['#attached'].

File

core/modules/system/src/Tests/Render/HtmlResponseAttachmentsTest.php, line 29
Contains \Drupal\system\Tests\Render\HtmlResponseAttachmentsTest.

Class

HtmlResponseAttachmentsTest
Functional tests for HtmlResponseAttachmentsProcessor.

Namespace

Drupal\system\Tests\Render

Code

public function testAttachments() {

  // Test ['#attached']['http_header] = ['Status', $code].
  $this
    ->drupalGet('/render_attached_test/teapot');
  $this
    ->assertResponse(418);
  $this
    ->assertHeader('X-Drupal-Cache', 'MISS');

  // Repeat for the cache.
  $this
    ->drupalGet('/render_attached_test/teapot');
  $this
    ->assertResponse(418);
  $this
    ->assertHeader('X-Drupal-Cache', 'HIT');

  // Test ['#attached']['http_header'] with various replacement rules.
  $this
    ->drupalGet('/render_attached_test/header');
  $this
    ->assertTeapotHeaders();
  $this
    ->assertHeader('X-Drupal-Cache', 'MISS');

  // Repeat for the cache.
  $this
    ->drupalGet('/render_attached_test/header');
  $this
    ->assertHeader('X-Drupal-Cache', 'HIT');

  // Test ['#attached']['feed'].
  $this
    ->drupalGet('/render_attached_test/feed');
  $this
    ->assertHeader('X-Drupal-Cache', 'MISS');
  $this
    ->assertFeed();

  // Repeat for the cache.
  $this
    ->drupalGet('/render_attached_test/feed');
  $this
    ->assertHeader('X-Drupal-Cache', 'HIT');

  // Test ['#attached']['html_head'].
  $this
    ->drupalGet('/render_attached_test/head');
  $this
    ->assertHeader('X-Drupal-Cache', 'MISS');
  $this
    ->assertHead();

  // Repeat for the cache.
  $this
    ->drupalGet('/render_attached_test/head');
  $this
    ->assertHeader('X-Drupal-Cache', 'HIT');
}