public function TourCacheTagsTest::testRenderedTour in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/tour/src/Tests/TourCacheTagsTest.php \Drupal\tour\Tests\TourCacheTagsTest::testRenderedTour()
Tests cache tags presence and invalidation of the Tour entity.
Tests the following cache tags:
- 'tour:<tour ID>'
File
- core/
modules/ tour/ src/ Tests/ TourCacheTagsTest.php, line 46 - Contains \Drupal\tour\Tests\TourCacheTagsTest.
Class
- TourCacheTagsTest
- Tests the Tour entity's cache tags.
Namespace
Drupal\tour\TestsCode
public function testRenderedTour() {
$url = Url::fromRoute('tour_test.1');
// Prime the page cache.
$this
->verifyPageCache($url, 'MISS');
// Verify a cache hit, but also the presence of the correct cache tags.
$expected_tags = [
'config:tour.tour.tour-test',
'config:user.role.anonymous',
'rendered',
];
$this
->verifyPageCache($url, 'HIT', $expected_tags);
// Verify that after modifying the tour, there is a cache miss.
$this
->pass('Test modification of tour.', 'Debug');
Tour::load('tour-test')
->save();
$this
->verifyPageCache($url, 'MISS');
// Verify a cache hit.
$this
->verifyPageCache($url, 'HIT', $expected_tags);
// Verify that after deleting the tour, there is a cache miss.
$this
->pass('Test deletion of tour.', 'Debug');
Tour::load('tour-test')
->delete();
$this
->verifyPageCache($url, 'MISS');
// Verify a cache hit.
$expected_tags = [
'config:user.role.anonymous',
'rendered',
];
$this
->verifyPageCache($url, 'HIT', $expected_tags);
}