function TourCacheTagsTest::testRenderedTour

Same name and namespace in other branches
  1. 8.9.x core/modules/tour/tests/src/Functional/TourCacheTagsTest.php \Drupal\Tests\tour\Functional\TourCacheTagsTest::testRenderedTour()
  2. 10 core/modules/tour/tests/src/Functional/TourCacheTagsTest.php \Drupal\Tests\tour\Functional\TourCacheTagsTest::testRenderedTour()
  3. 11.x core/modules/tour/tests/src/Functional/TourCacheTagsTest.php \Drupal\Tests\tour\Functional\TourCacheTagsTest::testRenderedTour()

Tests cache tags presence and invalidation of the Tour entity.

Tests the following cache tags:

  • 'tour:<tour ID>'

File

core/modules/tour/tests/src/Functional/TourCacheTagsTest.php, line 46

Class

TourCacheTagsTest
Tests the Tour entity&#039;s cache tags.

Namespace

Drupal\Tests\tour\Functional

Code

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',
        'http_response',
        'rendered',
    ];
    $this->verifyPageCache($url, 'HIT', $expected_tags);
    // Verify that after modifying the tour, there is a cache miss.
    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.
    Tour::load('tour-test')->delete();
    $this->verifyPageCache($url, 'MISS');
    // Verify a cache hit.
    $expected_tags = [
        'config:user.role.anonymous',
        'http_response',
        'rendered',
    ];
    $this->verifyPageCache($url, 'HIT', $expected_tags);
}

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