diff --git a/core/modules/system/src/Tests/Render/HtmlResponseAttachmentsTest.php b/core/modules/system/src/Tests/Render/HtmlResponseAttachmentsTest.php index eb98cb8..3571efb 100644 --- a/core/modules/system/src/Tests/Render/HtmlResponseAttachmentsTest.php +++ b/core/modules/system/src/Tests/Render/HtmlResponseAttachmentsTest.php @@ -27,35 +27,68 @@ class HtmlResponseAttachmentsTest extends WebTestBase { * Test rendering of ['#attached']. */ public function testAttachments() { - // We only have one test method here in order to speed up test execution. + // 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']['html_head'] with various replacement rules. $this->drupalGet('/render_attached_test/head'); $this->assertHeader('X-Test-Teapot', 'Teapot Mode Active'); $this->assertHeader('X-Test-Teapot-Replace', 'Teapot replaced'); $this->assertHeader('X-Test-Teapot-No-Replace', 'This value is not replaced,This one is added'); + $this->assertHeader('X-Drupal-Cache', 'MISS'); + // Repeat for the cache. + $this->drupalGet('/render_attached_test/head'); + $this->assertHeader('X-Drupal-Cache', 'HIT'); + // Test ['#attached']['feed']. + // @todo: Improve this test. $this->drupalGet('/render_attached_test/feed'); $this->assertEqual(1, count($this->xpath('//head/link[@rel="alternate"]')), 'Link has rel="alternate"'); $this->assertEqual(1, count($this->xpath('//head/link[@type="application/rss+xml"]')), 'Link has proper content type.'); $this->assertEqual(1, count($this->xpath('//head/link[@href="test://url"]')), 'Link has URL.'); $this->assertEqual(1, count($this->xpath('//head/link[@title=""]')), 'Link has title.'); + $this->assertHeader('X-Drupal-Cache', 'MISS'); + // Repeat for the cache. + $this->drupalGet('/render_attached_test/feed'); + $this->assertHeader('X-Drupal-Cache', 'HIT'); // Now repeat the process using drupal_process_attached(). + // Test ['#attached']['http_header] = ['Status', $code]. $this->drupalGet('/render_attached_test/teapot_dpa'); $this->assertResponse(418); + $this->assertHeader('X-Drupal-Cache', 'MISS'); + // Repeat for the cache. + $this->drupalGet('/render_attached_test/teapot_dpa'); + $this->assertResponse(418); + $this->assertHeader('X-Drupal-Cache', 'HIT'); + // Test ['#attached']['html_head'] with various replacement rules. $this->drupalGet('/render_attached_test/head_dpa'); $this->assertHeader('X-Test-Teapot', 'Teapot Mode Active'); $this->assertHeader('X-Test-Teapot-Replace', 'Teapot replaced'); $this->assertHeader('X-Test-Teapot-No-Replace', 'This value is not replaced,This one is added'); + $this->assertHeader('X-Drupal-Cache', 'MISS'); + // Repeat for the cache. + $this->drupalGet('/render_attached_test/head_dpa'); + $this->assertHeader('X-Drupal-Cache', 'HIT'); + // Test ['#attached']['feed']. + // @todo: Improve this test. $this->drupalGet('/render_attached_test/feed_dpa'); $this->assertEqual(1, count($this->xpath('//head/link[@rel="alternate"]')), 'Link has rel="alternate"'); $this->assertEqual(1, count($this->xpath('//head/link[@type="application/rss+xml"]')), 'Link has proper content type.'); $this->assertEqual(1, count($this->xpath('//head/link[@href="test://url"]')), 'Link has URL.'); $this->assertEqual(1, count($this->xpath('//head/link[@title=""]')), 'Link has title.'); + $this->assertHeader('X-Drupal-Cache', 'MISS'); + // Repeat for the cache. + $this->drupalGet('/render_attached_test/feed_dpa'); + $this->assertHeader('X-Drupal-Cache', 'HIT'); } }