function VariationCacheTest::assertVariationCacheItem

Same name in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php \Drupal\Tests\Core\Cache\VariationCacheTest::assertVariationCacheItem()

Asserts that an item was properly stored in the variation cache.

Parameters

mixed $data: The data that should have been stored.

\Drupal\Core\Cache\CacheableMetadata $cacheability: The cacheability that should have been used.

\Drupal\Core\Cache\CacheableMetadata $initial_cacheability: The initial cacheability that should be used.

4 calls to VariationCacheTest::assertVariationCacheItem()
VariationCacheTest::testNestedVariations in core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php
Tests a cache item that has nested variations.
VariationCacheTest::testNestedVariationsSelfHealing in core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php
Tests a cache item that has nested variations that trigger self-healing.
VariationCacheTest::testNoVariations in core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php
Tests a cache item that has no variations.
VariationCacheTest::testSingleVariation in core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php
Tests a cache item that only ever varies by one context.

File

core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php, line 467

Class

VariationCacheTest
@coversDefaultClass \Drupal\Core\Cache\VariationCache @group Cache

Namespace

Drupal\Tests\Core\Cache

Code

protected function assertVariationCacheItem($data, CacheableMetadata $cacheability, CacheableMetadata $initial_cacheability) {
    $cache_item = $this->variationCache
        ->get($this->cacheKeys, $initial_cacheability);
    $this->assertNotFalse($cache_item, 'Variable data was stored and retrieved successfully.');
    $this->assertEquals($data, $cache_item->data, 'Variable cache item contains the right data.');
    $this->assertSame($cacheability->getCacheTags(), $cache_item->tags, 'Variable cache item uses the right cache tags.');
}

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