You are here

public function VariationCacheTest::testSingleVariation in VariationCache 8

Tests a cache item that only ever varies by one context.

@covers ::get @covers ::set

File

tests/src/Unit/VariationCacheTest.php, line 194

Class

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

Namespace

Drupal\Tests\variationcache\Unit

Code

public function testSingleVariation() {
  $cacheability = $this->housingTypeCacheability;
  $house_data = [
    'apartment' => 'You have a nice apartment',
    'house' => 'You have a nice house',
  ];
  foreach ($house_data as $housing_type => $data) {
    $this->housingType = $housing_type;
    $this
      ->assertVariationCacheMiss($cacheability);
    $this
      ->setVariationCacheItem($data, $cacheability, $cacheability);
    $this
      ->assertVariationCacheItem($data, $cacheability, $cacheability);
    $this
      ->assertCacheBackendItem("{$this->cacheIdBase}:ht.{$housing_type}", $data, $cacheability);
  }
}