function VariationCacheTest::testNoVariations

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Core/Cache/VariationCacheTest.php \Drupal\Tests\Core\Cache\VariationCacheTest::testNoVariations()

Tests a cache item that has no variations.

@covers ::get @covers ::set

File

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

Class

VariationCacheTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Cache%21VariationCache.php/class/VariationCache/11.x" title="Wraps a regular cache backend to make it support cache contexts." class="local">\Drupal\Core\Cache\VariationCache</a> @group Cache

Namespace

Drupal\Tests\Core\Cache

Code

public function testNoVariations() : void {
    $data = 'You have a nice house!';
    $cacheability = (new CacheableMetadata())->setCacheTags([
        'bar',
        'foo',
    ]);
    $initial_cacheability = (new CacheableMetadata())->setCacheTags([
        'foo',
    ]);
    $this->setVariationCacheItem($data, $cacheability, $initial_cacheability);
    $this->assertVariationCacheItem($data, $cacheability, $initial_cacheability);
}

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