public function ToolbarCacheContextsTest::testCacheIntegration in Drupal 10
Same name and namespace in other branches
- 8 core/modules/toolbar/tests/src/Functional/ToolbarCacheContextsTest.php \Drupal\Tests\toolbar\Functional\ToolbarCacheContextsTest::testCacheIntegration()
- 9 core/modules/toolbar/tests/src/Functional/ToolbarCacheContextsTest.php \Drupal\Tests\toolbar\Functional\ToolbarCacheContextsTest::testCacheIntegration()
Tests toolbar cache integration.
File
- core/
modules/ toolbar/ tests/ src/ Functional/ ToolbarCacheContextsTest.php, line 69
Class
- ToolbarCacheContextsTest
- Tests the cache contexts for toolbar.
Namespace
Drupal\Tests\toolbar\FunctionalCode
public function testCacheIntegration() {
$this
->installExtraModules([
'csrf_test',
'dynamic_page_cache',
]);
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('test-page');
$this
->assertSession()
->responseHeaderEquals('X-Drupal-Dynamic-Cache', 'MISS');
$this
->assertCacheContexts([
'session',
'user',
'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT,
], 'Expected cache contexts found with CSRF token link.');
$this
->drupalGet('test-page');
$this
->assertSession()
->responseHeaderEquals('X-Drupal-Dynamic-Cache', 'HIT');
$this
->assertCacheContexts([
'session',
'user',
'url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT,
], 'Expected cache contexts found with CSRF token link.');
}