function BigPipeTest::testDebugCacheability

Tests that response contains cacheability debug comments.

File

core/modules/big_pipe/tests/src/Functional/BigPipeTest.php, line 562

Class

BigPipeTest
Tests BigPipe's no-JS detection & response delivery (with and without JS).

Namespace

Drupal\Tests\big_pipe\Functional

Code

public function testDebugCacheability() : void {
    $this->drupalLogin($this->rootUser);
    $this->assertSessionCookieExists('1');
    $this->assertBigPipeNoJsCookieExists('0');
    // With debug_cacheability_headers enabled.
    $this->drupalGet(Url::fromRoute('<front>'));
    $this->assertBigPipeResponseHeadersPresent();
    $this->assertSession()
        ->responseContains('<!-- big_pipe cache tags:  -->');
    $this->assertSession()
        ->responseContains('<!-- big_pipe cache contexts: languages:language_interface theme user.permissions -->');
    // With debug_cacheability_headers disabled.
    $this->setContainerParameter('http.response.debug_cacheability_headers', FALSE);
    $this->rebuildContainer();
    $this->resetAll();
    $this->drupalGet(Url::fromRoute('<front>'));
    $this->assertSession()
        ->responseNotContains('<!-- big_pipe cache tags:');
    $this->assertSession()
        ->responseNotContains('<!-- big_pipe cache contexts:');
}

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