function CacheTest::testMergeCacheContexts

Same name in other branches
  1. 10 core/tests/Drupal/Tests/Core/Cache/CacheTest.php \Drupal\Tests\Core\Cache\CacheTest::testMergeCacheContexts()
  2. 11.x 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));
}

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