protected function VariationCacheTest::assertCacheBackendItem in VariationCache 8
Asserts that an item was properly stored in the cache backend.
Parameters
string $cid: The cache ID that should have been used.
mixed $data: The data that should have been stored.
\Drupal\Core\Cache\CacheableMetadata|null $cacheability: (optional) The cacheability that should have been used. Does not apply when checking for cache redirects.
4 calls to VariationCacheTest::assertCacheBackendItem()
- VariationCacheTest::testNestedVariations in tests/
src/ Unit/ VariationCacheTest.php - Tests a cache item that has nested variations.
- VariationCacheTest::testNestedVariationsSelfHealing in tests/
src/ Unit/ VariationCacheTest.php - Tests a cache item that has nested variations that trigger self-healing.
- VariationCacheTest::testSingleVariation in tests/
src/ Unit/ VariationCacheTest.php - Tests a cache item that only ever varies by one context.
- VariationCacheTest::testSplitVariationsSelfHealing in tests/
src/ Unit/ VariationCacheTest.php - Tests self-healing for a cache item that has split variations.
File
- tests/
src/ Unit/ VariationCacheTest.php, line 464
Class
- VariationCacheTest
- @coversDefaultClass \Drupal\variationcache\Cache\VariationCache @group Cache
Namespace
Drupal\Tests\variationcache\UnitCode
protected function assertCacheBackendItem($cid, $data, CacheableMetadata $cacheability = NULL) {
$cache_backend_item = $this->memoryBackend
->get($cid);
$this
->assertNotFalse($cache_backend_item, 'The data was stored and retrieved successfully.');
$this
->assertEquals($data, $cache_backend_item->data, 'Cache item contains the right data.');
if ($data instanceof CacheRedirect) {
$this
->assertSame([], $cache_backend_item->tags, 'A cache redirect does not use cache tags.');
$this
->assertSame(-1, $cache_backend_item->expire, 'A cache redirect is stored indefinitely.');
}
else {
$this
->assertSame($cacheability
->getCacheTags(), $cache_backend_item->tags, 'Cache item uses the right cache tags.');
}
}