function CacheContextsManagerTest::testOptimizeTokens
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::testOptimizeTokens()
- 10 core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::testOptimizeTokens()
- 11.x core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::testOptimizeTokens()
@covers ::optimizeTokens
@dataProvider providerTestOptimizeTokens
File
-
core/
tests/ Drupal/ Tests/ Core/ Cache/ Context/ CacheContextsManagerTest.php, line 29
Class
- CacheContextsManagerTest
- @coversDefaultClass \Drupal\Core\Cache\Context\CacheContextsManager @group Cache
Namespace
Drupal\Tests\Core\Cache\ContextCode
public function testOptimizeTokens(array $context_tokens, array $optimized_context_tokens) {
$container = $this->getMockBuilder('Drupal\\Core\\DependencyInjection\\Container')
->disableOriginalConstructor()
->getMock();
$container->expects($this->any())
->method('get')
->will($this->returnValueMap([
[
'cache_context.a',
Container::EXCEPTION_ON_INVALID_REFERENCE,
new FooCacheContext(),
],
[
'cache_context.a.b',
Container::EXCEPTION_ON_INVALID_REFERENCE,
new FooCacheContext(),
],
[
'cache_context.a.b.c',
Container::EXCEPTION_ON_INVALID_REFERENCE,
new BazCacheContext(),
],
[
'cache_context.x',
Container::EXCEPTION_ON_INVALID_REFERENCE,
new BazCacheContext(),
],
[
'cache_context.a.b.no-optimize',
Container::EXCEPTION_ON_INVALID_REFERENCE,
new NoOptimizeCacheContext(),
],
]));
$cache_contexts_manager = new CacheContextsManager($container, $this->getContextsFixture());
$this->assertSame($optimized_context_tokens, $cache_contexts_manager->optimizeTokens($context_tokens));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.