function WorkspaceSwitcherTest::testToolbarSwitcherDynamicPageCache

Same name in other branches
  1. 11.x core/modules/workspaces/tests/src/Functional/WorkspaceSwitcherTest.php \Drupal\Tests\workspaces\Functional\WorkspaceSwitcherTest::testToolbarSwitcherDynamicPageCache()

Tests that the toolbar workspace switcher doesn't disable the page cache.

File

core/modules/workspaces/tests/src/Functional/WorkspaceSwitcherTest.php, line 106

Class

WorkspaceSwitcherTest
Tests workspace switching functionality.

Namespace

Drupal\Tests\workspaces\Functional

Code

public function testToolbarSwitcherDynamicPageCache() : void {
    $this->drupalLogin($this->drupalCreateUser([
        'access toolbar',
        'view any workspace',
    ]));
    // Front-page is visited right after login.
    $this->assertSession()
        ->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'MISS');
    // Reload the page, it should be cached now.
    $this->drupalGet(Url::fromRoute('<front>'));
    $this->assertSession()
        ->elementExists('css', '.workspaces-toolbar-tab');
    $this->assertSession()
        ->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
}

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