function AnnouncementsCacheTest::testDynamicPageCache
Same name in other branches
- 11.x core/modules/announcements_feed/tests/src/Functional/AnnouncementsCacheTest.php \Drupal\Tests\announcements_feed\Functional\AnnouncementsCacheTest::testDynamicPageCache()
Tests dynamic page cache.
File
-
core/
modules/ announcements_feed/ tests/ src/ Functional/ AnnouncementsCacheTest.php, line 35
Class
- AnnouncementsCacheTest
- Defines a class for testing pages are still cacheable with dynamic page cache.
Namespace
Drupal\Tests\announcements_feed\FunctionalCode
public function testDynamicPageCache() : void {
$this->drupalLogin($this->drupalCreateUser([
'access toolbar',
'access announcements',
]));
// 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', '[data-drupal-announce-trigger]');
$this->assertSession()
->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.