You are here

public function CacheTest::testMergeCacheContexts in Drupal 9

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

@covers ::mergeContexts

@dataProvider mergeCacheContextsProvide

File

core/tests/Drupal/Tests/Core/Cache/CacheTest.php, line 142

Class

CacheTest
@coversDefaultClass \Drupal\Core\Cache\Cache @group Cache

Namespace

Drupal\Tests\Core\Cache

Code

public function testMergeCacheContexts(array $expected, ...$contexts) {
  $cache_contexts_manager = $this
    ->prophesize(CacheContextsManager::class);
  $cache_contexts_manager
    ->assertValidTokens(Argument::any())
    ->willReturn(TRUE);
  $container = $this
    ->prophesize(Container::class);
  $container
    ->get('cache_contexts_manager')
    ->willReturn($cache_contexts_manager
    ->reveal());
  \Drupal::setContainer($container
    ->reveal());
  $this
    ->assertEqualsCanonicalizing($expected, Cache::mergeContexts(...$contexts));
}