summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2015-04-16 13:34:23 (GMT)
committerNathaniel Catchpole2015-04-16 13:34:23 (GMT)
commit7c88cb724d8d07d581b90563cf3f7114dda8178c (patch)
treed185f8b043cd07d74518a590166ed7759d8a2afe
parentfc59ba20828f15f6bcc2a9c15f5c024665ef5430 (diff)
Issue #2468151 by lhangea, rpayanm, Palashvijay4O: Rename the CacheContexts service to CacheContextsManager
-rw-r--r--core/core.services.yml10
-rw-r--r--core/lib/Drupal/Core/Access/AccessResult.php2
-rw-r--r--core/lib/Drupal/Core/Cache/Cache.php2
-rw-r--r--core/lib/Drupal/Core/Cache/CacheContextsManager.php (renamed from core/lib/Drupal/Core/Cache/CacheContexts.php)8
-rw-r--r--core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php8
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php16
-rw-r--r--core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php16
-rw-r--r--core/lib/Drupal/Core/Render/Renderer.php16
-rw-r--r--core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php2
-rw-r--r--core/modules/system/src/Tests/Entity/EntityViewBuilderTest.php10
-rw-r--r--core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php2
-rw-r--r--core/modules/views/src/Plugin/views/cache/CachePluginBase.php2
-rw-r--r--core/tests/Drupal/Tests/Core/Cache/CacheContextsManagerTest.php (renamed from core/tests/Drupal/Tests/Core/Cache/CacheContextsTest.php)32
-rw-r--r--core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Render/RendererPostRenderCacheTest.php4
-rw-r--r--core/tests/Drupal/Tests/Core/Render/RendererTestBase.php10
16 files changed, 72 insertions, 72 deletions
diff --git a/core/core.services.yml b/core/core.services.yml
index 53a2725..dacfcc7 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -111,8 +111,8 @@ services:
arguments: ['@settings', '%cache_default_bin_backends%']
calls:
- [setContainer, ['@service_container']]
- cache_contexts:
- class: Drupal\Core\Cache\CacheContexts
+ cache_contexts_manager:
+ class: Drupal\Core\Cache\CacheContextsManager
arguments: ['@service_container', '%cache_contexts%' ]
cache_tags.invalidator:
parent: container.trait
@@ -856,7 +856,7 @@ services:
- { name: event_subscriber }
main_content_renderer.html:
class: Drupal\Core\Render\MainContent\HtmlRenderer
- arguments: ['@title_resolver', '@plugin.manager.display_variant', '@event_dispatcher', '@element_info', '@module_handler', '@renderer', '@cache_contexts']
+ arguments: ['@title_resolver', '@plugin.manager.display_variant', '@event_dispatcher', '@element_info', '@module_handler', '@renderer', '@cache_contexts_manager']
tags:
- { name: render.main_content_renderer, format: html }
main_content_renderer.ajax:
@@ -961,7 +961,7 @@ services:
class: Drupal\Core\EventSubscriber\FinishResponseSubscriber
tags:
- { name: event_subscriber }
- arguments: ['@language_manager', '@config.factory', '@page_cache_request_policy', '@page_cache_response_policy', '@cache_contexts']
+ arguments: ['@language_manager', '@config.factory', '@page_cache_request_policy', '@page_cache_response_policy', '@cache_contexts_manager']
redirect_response_subscriber:
class: Drupal\Core\EventSubscriber\RedirectResponseSubscriber
arguments: ['@url_generator', '@router.request_context']
@@ -1351,6 +1351,6 @@ services:
lazy: true
renderer:
class: Drupal\Core\Render\Renderer
- arguments: ['@controller_resolver', '@theme.manager', '@plugin.manager.element_info', '@request_stack', '@cache_factory', '@cache_contexts', '%renderer.config%']
+ arguments: ['@controller_resolver', '@theme.manager', '@plugin.manager.element_info', '@request_stack', '@cache_factory', '@cache_contexts_manager', '%renderer.config%']
email.validator:
class: Egulias\EmailValidator\EmailValidator
diff --git a/core/lib/Drupal/Core/Access/AccessResult.php b/core/lib/Drupal/Core/Access/AccessResult.php
index 6188b34..741f2ed 100644
--- a/core/lib/Drupal/Core/Access/AccessResult.php
+++ b/core/lib/Drupal/Core/Access/AccessResult.php
@@ -32,7 +32,7 @@ abstract class AccessResult implements AccessResultInterface, CacheableDependenc
* The cache context IDs (to vary a cache item ID based on active contexts).
*
* @see \Drupal\Core\Cache\CacheContextInterface
- * @see \Drupal\Core\Cache\CacheContexts::convertTokensToKeys()
+ * @see \Drupal\Core\Cache\CacheContextsManager::convertTokensToKeys()
*
* @var string[]
*/
diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php
index 5541a68..d149592 100644
--- a/core/lib/Drupal/Core/Cache/Cache.php
+++ b/core/lib/Drupal/Core/Cache/Cache.php
@@ -37,7 +37,7 @@ class Cache {
$cache_contexts = array_merge($cache_contexts, $contexts);
}
$cache_contexts = array_unique($cache_contexts);
- \Drupal::service('cache_contexts')->validateTokens($cache_contexts);
+ \Drupal::service('cache_contexts_manager')->validateTokens($cache_contexts);
sort($cache_contexts);
return $cache_contexts;
}
diff --git a/core/lib/Drupal/Core/Cache/CacheContexts.php b/core/lib/Drupal/Core/Cache/CacheContextsManager.php
index bede04d..67857cb 100644
--- a/core/lib/Drupal/Core/Cache/CacheContexts.php
+++ b/core/lib/Drupal/Core/Cache/CacheContextsManager.php
@@ -2,7 +2,7 @@
/**
* @file
- * Contains \Drupal\Core\Cache\CacheContexts.
+ * Contains \Drupal\Core\Cache\CacheContextsManager.
*/
namespace Drupal\Core\Cache;
@@ -25,7 +25,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* @see \Drupal\Core\Cache\CalculatedCacheContextInterface
* @see \Drupal\Core\Cache\CacheContextsPass
*/
-class CacheContexts {
+class CacheContextsManager {
/**
* The service container.
@@ -42,7 +42,7 @@ class CacheContexts {
protected $contexts;
/**
- * Constructs a CacheContexts object.
+ * Constructs a CacheContextsManager object.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The current service container.
@@ -231,7 +231,7 @@ class CacheContexts {
*
* @throws \LogicException
*
- * @see \Drupal\Core\Cache\CacheContexts::parseTokens()
+ * @see \Drupal\Core\Cache\CacheContextsManager::parseTokens()
*/
public function validateTokens(array $context_tokens = []) {
if (empty($context_tokens)) {
diff --git a/core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php b/core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php
index 1d447a1..f415064 100644
--- a/core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php
+++ b/core/lib/Drupal/Core/Cache/CacheableDependencyInterface.php
@@ -24,14 +24,14 @@ interface CacheableDependencyInterface {
* These identify a specific variation/representation of the object.
*
* Cache contexts are tokens: placeholders that are converted to cache keys by
- * the @cache_contexts service. The replacement value depends on the request
- * context (the current URL, language, and so on). They're converted before
- * storing an object in cache.
+ * the @cache_contexts_manager service. The replacement value depends on the
+ * request context (the current URL, language, and so on). They're converted
+ * before storing an object in cache.
*
* @return string[]
* An array of cache context tokens, used to generate a cache ID.
*
- * @see \Drupal\Core\Cache\CacheContexts::convertTokensToKeys()
+ * @see \Drupal\Core\Cache\CacheContextsManager::convertTokensToKeys()
*/
public function getCacheContexts();
diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
index 157454d..d29c052 100644
--- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
@@ -10,7 +10,7 @@ namespace Drupal\Core\EventSubscriber;
use Drupal\Component\Datetime\DateTimePlus;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
-use Drupal\Core\Cache\CacheContexts;
+use Drupal\Core\Cache\CacheContextsManager;
use Drupal\Core\Config\Config;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Language\LanguageManagerInterface;
@@ -61,9 +61,9 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
protected $responsePolicy;
/**
- * The cache contexts service.
+ * The cache contexts manager service.
*
- * @var \Drupal\Core\Cache\CacheContexts
+ * @var \Drupal\Core\Cache\CacheContextsManager
*/
protected $cacheContexts;
@@ -78,15 +78,15 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
* A policy rule determining the cacheability of a request.
* @param \Drupal\Core\PageCache\ResponsePolicyInterface $response_policy
* A policy rule determining the cacheability of a response.
- * @param \Drupal\Core\Cache\CacheContexts $cache_contexts
- * The cache contexts service.
+ * @param \Drupal\Core\Cache\CacheContextsManager $cache_contexts_manager
+ * The cache contexts manager service.
*/
- public function __construct(LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, RequestPolicyInterface $request_policy, ResponsePolicyInterface $response_policy, CacheContexts $cache_contexts) {
+ public function __construct(LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, RequestPolicyInterface $request_policy, ResponsePolicyInterface $response_policy, CacheContextsManager $cache_contexts_manager) {
$this->languageManager = $language_manager;
$this->config = $config_factory->get('system.performance');
$this->requestPolicy = $request_policy;
$this->responsePolicy = $response_policy;
- $this->cacheContexts = $cache_contexts;
+ $this->cacheContextsManager = $cache_contexts_manager;
}
/**
@@ -179,7 +179,7 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
$existing_cache_contexts = explode(' ', $response->headers->get('X-Drupal-Cache-Contexts'));
$cache_contexts = Cache::mergeContexts($existing_cache_contexts, $cache_contexts);
}
- $response->headers->set('X-Drupal-Cache-Contexts', implode(' ', $this->cacheContexts->optimizeTokens($cache_contexts)));
+ $response->headers->set('X-Drupal-Cache-Contexts', implode(' ', $this->cacheContextsManager->optimizeTokens($cache_contexts)));
}
/**
diff --git a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php
index d12522a..17568d1 100644
--- a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php
+++ b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php
@@ -10,7 +10,7 @@ namespace Drupal\Core\Render\MainContent;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\Cache;
-use Drupal\Core\Cache\CacheContexts;
+use Drupal\Core\Cache\CacheContextsManager;
use Drupal\Core\Controller\TitleResolverInterface;
use Drupal\Core\Display\PageVariantInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
@@ -73,9 +73,9 @@ class HtmlRenderer implements MainContentRendererInterface {
protected $renderer;
/**
- * The cache contexts service.
+ * The cache contexts manager service.
*
- * @var \Drupal\Core\Cache\CacheContexts
+ * @var \Drupal\Core\Cache\CacheContextsManager
*/
protected $cacheContexts;
@@ -94,17 +94,17 @@ class HtmlRenderer implements MainContentRendererInterface {
* The module handler.
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer service.
- * @param \Drupal\Core\Cache\CacheContexts $cache_contexts
- * The cache contexts service.
+ * @param \Drupal\Core\Cache\CacheContextsManager $cache_contexts_manager
+ * The cache contexts manager service.
*/
- public function __construct(TitleResolverInterface $title_resolver, PluginManagerInterface $display_variant_manager, EventDispatcherInterface $event_dispatcher, ElementInfoManagerInterface $element_info_manager, ModuleHandlerInterface $module_handler, RendererInterface $renderer, CacheContexts $cache_contexts) {
+ public function __construct(TitleResolverInterface $title_resolver, PluginManagerInterface $display_variant_manager, EventDispatcherInterface $event_dispatcher, ElementInfoManagerInterface $element_info_manager, ModuleHandlerInterface $module_handler, RendererInterface $renderer, CacheContextsManager $cache_contexts_manager) {
$this->titleResolver = $title_resolver;
$this->displayVariantManager = $display_variant_manager;
$this->eventDispatcher = $event_dispatcher;
$this->elementInfoManager = $element_info_manager;
$this->moduleHandler = $module_handler;
$this->renderer = $renderer;
- $this->cacheContexts = $cache_contexts;
+ $this->cacheContextsManager = $cache_contexts_manager;
}
/**
@@ -169,7 +169,7 @@ class HtmlRenderer implements MainContentRendererInterface {
$response = new Response($content, 200,[
'X-Drupal-Cache-Tags' => implode(' ', $cache_tags),
- 'X-Drupal-Cache-Contexts' => implode(' ', $this->cacheContexts->optimizeTokens($cache_contexts)),
+ 'X-Drupal-Cache-Contexts' => implode(' ', $this->cacheContextsManager->optimizeTokens($cache_contexts)),
'X-Generator' => 'Drupal ' . $version . ' (https://www.drupal.org)'
]);
return $response;
diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php
index 5041a78..096551b 100644
--- a/core/lib/Drupal/Core/Render/Renderer.php
+++ b/core/lib/Drupal/Core/Render/Renderer.php
@@ -11,7 +11,7 @@ use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableDependencyInterface;
-use Drupal\Core\Cache\CacheContexts;
+use Drupal\Core\Cache\CacheContextsManager;
use Drupal\Core\Cache\CacheFactoryInterface;
use Drupal\Core\Controller\ControllerResolverInterface;
use Drupal\Core\Theme\ThemeManagerInterface;
@@ -59,9 +59,9 @@ class Renderer implements RendererInterface {
protected $cacheFactory;
/**
- * The cache contexts service.
+ * The cache contexts manager service.
*
- * @var \Drupal\Core\Cache\CacheContexts
+ * @var \Drupal\Core\Cache\CacheContextsManager
*/
protected $cacheContexts;
@@ -92,18 +92,18 @@ class Renderer implements RendererInterface {
* The request stack.
* @param \Drupal\Core\Cache\CacheFactoryInterface $cache_factory
* The cache factory.
- * @param \Drupal\Core\Cache\CacheContexts $cache_contexts
- * The cache contexts service.
+ * @param \Drupal\Core\Cache\CacheContextsManager $cache_contexts_manager
+ * The cache contexts manager service.
* @param array $renderer_config
* The renderer configuration array.
*/
- public function __construct(ControllerResolverInterface $controller_resolver, ThemeManagerInterface $theme, ElementInfoManagerInterface $element_info, RequestStack $request_stack, CacheFactoryInterface $cache_factory, CacheContexts $cache_contexts, array $renderer_config) {
+ public function __construct(ControllerResolverInterface $controller_resolver, ThemeManagerInterface $theme, ElementInfoManagerInterface $element_info, RequestStack $request_stack, CacheFactoryInterface $cache_factory, CacheContextsManager $cache_contexts_manager, array $renderer_config) {
$this->controllerResolver = $controller_resolver;
$this->theme = $theme;
$this->elementInfo = $element_info;
$this->requestStack = $request_stack;
$this->cacheFactory = $cache_factory;
- $this->cacheContexts = $cache_contexts;
+ $this->cacheContextsManager = $cache_contexts_manager;
$this->rendererConfig = $renderer_config;
}
@@ -755,7 +755,7 @@ class Renderer implements RendererInterface {
if (isset($elements['#cache']['keys'])) {
$cid_parts = $elements['#cache']['keys'];
if (!empty($elements['#cache']['contexts'])) {
- $contexts = $this->cacheContexts->convertTokensToKeys($elements['#cache']['contexts']);
+ $contexts = $this->cacheContextsManager->convertTokensToKeys($elements['#cache']['contexts']);
$cid_parts = array_merge($cid_parts, $contexts);
}
return implode(':', $cid_parts);
diff --git a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
index 23d5f79..91f98b3 100644
--- a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
+++ b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
@@ -632,7 +632,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase {
protected function createCacheId(array $keys, array $contexts) {
$cid_parts = $keys;
- $contexts = \Drupal::service('cache_contexts')->convertTokensToKeys($contexts);
+ $contexts = \Drupal::service('cache_contexts_manager')->convertTokensToKeys($contexts);
$cid_parts = array_merge($cid_parts, $contexts);
return implode(':', $cid_parts);
diff --git a/core/modules/system/src/Tests/Entity/EntityViewBuilderTest.php b/core/modules/system/src/Tests/Entity/EntityViewBuilderTest.php
index e44299b..dd275cb 100644
--- a/core/modules/system/src/Tests/Entity/EntityViewBuilderTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityViewBuilderTest.php
@@ -46,7 +46,7 @@ class EntityViewBuilderTest extends EntityUnitTestBase {
* Tests entity render cache handling.
*/
public function testEntityViewBuilderCache() {
- $cache_contexts = \Drupal::service("cache_contexts");
+ $cache_contexts_manager = \Drupal::service("cache_contexts_manager");
// Force a request via GET so we can get drupal_render() cache working.
$request = \Drupal::request();
@@ -63,7 +63,7 @@ class EntityViewBuilderTest extends EntityUnitTestBase {
// Get a fully built entity view render array.
$entity_test->save();
$build = $this->container->get('entity.manager')->getViewBuilder('entity_test')->view($entity_test, 'full');
- $cid_parts = array_merge($build['#cache']['keys'], $cache_contexts->convertTokensToKeys(Cache::mergeContexts($build['#cache']['contexts'], ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme'])));
+ $cid_parts = array_merge($build['#cache']['keys'], $cache_contexts_manager->convertTokensToKeys(Cache::mergeContexts($build['#cache']['contexts'], ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme'])));
$cid = implode(':', $cid_parts);
$bin = $build['#cache']['bin'];
@@ -95,7 +95,7 @@ class EntityViewBuilderTest extends EntityUnitTestBase {
* Tests entity render cache with references.
*/
public function testEntityViewBuilderCacheWithReferences() {
- $cache_contexts = \Drupal::service("cache_contexts");
+ $cache_contexts_manager = \Drupal::service("cache_contexts_manager");
// Force a request via GET so we can get drupal_render() cache working.
$request = \Drupal::request();
@@ -113,7 +113,7 @@ class EntityViewBuilderTest extends EntityUnitTestBase {
// Get a fully built entity view render array for the referenced entity.
$build = $this->container->get('entity.manager')->getViewBuilder('entity_test')->view($entity_test_reference, 'full');
- $cid_parts = array_merge($build['#cache']['keys'], $cache_contexts->convertTokensToKeys(Cache::mergeContexts($build['#cache']['contexts'], ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme'])));
+ $cid_parts = array_merge($build['#cache']['keys'], $cache_contexts_manager->convertTokensToKeys(Cache::mergeContexts($build['#cache']['contexts'], ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme'])));
$cid_reference = implode(':', $cid_parts);
$bin_reference = $build['#cache']['bin'];
@@ -132,7 +132,7 @@ class EntityViewBuilderTest extends EntityUnitTestBase {
// Get a fully built entity view render array.
$build = $this->container->get('entity.manager')->getViewBuilder('entity_test')->view($entity_test, 'full');
- $cid_parts = array_merge($build['#cache']['keys'], $cache_contexts->convertTokensToKeys(Cache::mergeContexts($build['#cache']['contexts'], ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme'])));
+ $cid_parts = array_merge($build['#cache']['keys'], $cache_contexts_manager->convertTokensToKeys(Cache::mergeContexts($build['#cache']['contexts'], ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme'])));
$cid = implode(':', $cid_parts);
$bin = $build['#cache']['bin'];
diff --git a/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php b/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php
index 2448cce..004603f 100644
--- a/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php
+++ b/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php
@@ -69,7 +69,7 @@ class PagerTestController extends ControllerBase {
* #pre_render callback for #type => pager that shows the pager cache context.
*/
public static function showPagerCacheContext(array $pager) {
- drupal_set_message(\Drupal::service('cache_contexts')->convertTokensToKeys(['url.query_args.pagers:' . $pager['#element']])[0]);
+ drupal_set_message(\Drupal::service('cache_contexts_manager')->convertTokensToKeys(['url.query_args.pagers:' . $pager['#element']])[0]);
return $pager;
}
diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
index c69b152..cafb613 100644
--- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
+++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
@@ -301,7 +301,7 @@ abstract class CachePluginBase extends PluginBase {
'items_per_page' => $this->view->getItemsPerPage(),
'offset' => $this->view->getOffset(),
];
- $key_data += \Drupal::service('cache_contexts')->convertTokensToKeys($this->displayHandler->getCacheMetadata()['contexts']);
+ $key_data += \Drupal::service('cache_contexts_manager')->convertTokensToKeys($this->displayHandler->getCacheMetadata()['contexts']);
$this->resultsKey = $this->view->storage->id() . ':' . $this->displayHandler->display['id'] . ':results:' . hash('sha256', serialize($key_data));
}
diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheContextsTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheContextsManagerTest.php
index 76251a1..416bd0e 100644
--- a/core/tests/Drupal/Tests/Core/Cache/CacheContextsTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/CacheContextsManagerTest.php
@@ -7,7 +7,7 @@
namespace Drupal\Tests\Core\Cache;
-use Drupal\Core\Cache\CacheContexts;
+use Drupal\Core\Cache\CacheContextsManager;
use Drupal\Core\Cache\CacheContextInterface;
use Drupal\Core\Cache\CalculatedCacheContextInterface;
use Drupal\Core\DependencyInjection\ContainerBuilder;
@@ -15,7 +15,7 @@ use Drupal\Tests\UnitTestCase;
use Symfony\Component\DependencyInjection\Container;
/**
- * @coversDefaultClass \Drupal\Core\Cache\CacheContexts
+ * @coversDefaultClass \Drupal\Core\Cache\CacheContextsManager
* @group Cache
*/
class CacheContextsTest extends UnitTestCase {
@@ -37,9 +37,9 @@ class CacheContextsTest extends UnitTestCase {
['a.b.c', Container::EXCEPTION_ON_INVALID_REFERENCE, new BazCacheContext()],
['x', Container::EXCEPTION_ON_INVALID_REFERENCE, new BazCacheContext()],
]));
- $cache_contexts = new CacheContexts($container, $this->getContextsFixture());
+ $cache_contexts_manager = new CacheContextsManager($container, $this->getContextsFixture());
- $this->assertSame($optimized_context_tokens, $cache_contexts->optimizeTokens($context_tokens));
+ $this->assertSame($optimized_context_tokens, $cache_contexts_manager->optimizeTokens($context_tokens));
}
/**
@@ -82,9 +82,9 @@ class CacheContextsTest extends UnitTestCase {
*/
public function testConvertTokensToKeys() {
$container = $this->getMockContainer();
- $cache_contexts = new CacheContexts($container, $this->getContextsFixture());
+ $cache_contexts_manager = new CacheContextsManager($container, $this->getContextsFixture());
- $new_keys = $cache_contexts->convertTokensToKeys([
+ $new_keys = $cache_contexts_manager->convertTokensToKeys([
'foo',
'baz:parameterA',
'baz:parameterB',
@@ -106,9 +106,9 @@ class CacheContextsTest extends UnitTestCase {
*/
public function testInvalidContext() {
$container = $this->getMockContainer();
- $cache_contexts = new CacheContexts($container, $this->getContextsFixture());
+ $cache_contexts_manager = new CacheContextsManager($container, $this->getContextsFixture());
- $cache_contexts->convertTokensToKeys(["non-cache-context"]);
+ $cache_contexts_manager->convertTokensToKeys(["non-cache-context"]);
}
/**
@@ -120,9 +120,9 @@ class CacheContextsTest extends UnitTestCase {
*/
public function testInvalidCalculatedContext($context_token) {
$container = $this->getMockContainer();
- $cache_contexts = new CacheContexts($container, $this->getContextsFixture());
+ $cache_contexts_manager = new CacheContextsManager($container, $this->getContextsFixture());
- $cache_contexts->convertTokensToKeys([$context_token]);
+ $cache_contexts_manager->convertTokensToKeys([$context_token]);
}
/**
@@ -136,15 +136,15 @@ class CacheContextsTest extends UnitTestCase {
}
public function testAvailableContextStrings() {
- $cache_contexts = new CacheContexts($this->getMockContainer(), $this->getContextsFixture());
- $contexts = $cache_contexts->getAll();
+ $cache_contexts_manager = new CacheContextsManager($this->getMockContainer(), $this->getContextsFixture());
+ $contexts = $cache_contexts_manager->getAll();
$this->assertEquals(array("foo", "baz"), $contexts);
}
public function testAvailableContextLabels() {
$container = $this->getMockContainer();
- $cache_contexts = new CacheContexts($container, $this->getContextsFixture());
- $labels = $cache_contexts->getLabels();
+ $cache_contexts_manager = new CacheContextsManager($container, $this->getContextsFixture());
+ $labels = $cache_contexts_manager->getLabels();
$expected = array("foo" => "Foo");
$this->assertEquals($expected, $labels);
}
@@ -205,12 +205,12 @@ class CacheContextsTest extends UnitTestCase {
*/
public function testValidateContexts(array $contexts, $expected_exception_message) {
$container = new ContainerBuilder();
- $cache_contexts = new CacheContexts($container, ['foo', 'foo.bar', 'baz']);
+ $cache_contexts_manager = new CacheContextsManager($container, ['foo', 'foo.bar', 'baz']);
if ($expected_exception_message !== FALSE) {
$this->setExpectedException('LogicException', $expected_exception_message);
}
// If it doesn't throw an exception, validateTokens() returns NULL.
- $this->assertNull($cache_contexts->validateTokens($contexts));
+ $this->assertNull($cache_contexts_manager->validateTokens($contexts));
}
}
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php b/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php
index 7e5abf4..7f86417 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php
@@ -40,7 +40,7 @@ class RendererBubblingTest extends RendererTestBase {
$this->elementInfo->expects($this->any())
->method('getInfo')
->willReturn([]);
- $this->cacheContexts->expects($this->any())
+ $this->cacheContextsManager->expects($this->any())
->method('convertTokensToKeys')
->willReturnArgument(0);
@@ -86,7 +86,7 @@ class RendererBubblingTest extends RendererTestBase {
public function testContextBubblingEdgeCases(array $element, array $expected_top_level_contexts, array $expected_cache_items) {
$this->setUpRequest();
$this->setupMemoryCache();
- $this->cacheContexts->expects($this->any())
+ $this->cacheContextsManager->expects($this->any())
->method('convertTokensToKeys')
->willReturnArgument(0);
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererPostRenderCacheTest.php b/core/tests/Drupal/Tests/Core/Render/RendererPostRenderCacheTest.php
index 99a639e..dd33b58 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererPostRenderCacheTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererPostRenderCacheTest.php
@@ -195,7 +195,7 @@ class RendererPostRenderCacheTest extends RendererTestBase {
public function testRenderChildrenPostRenderCacheDifferentContexts() {
$this->setUpRequest();
$this->setupMemoryCache();
- $this->cacheContexts->expects($this->any())
+ $this->cacheContextsManager->expects($this->any())
->method('convertTokensToKeys')
->willReturnArgument(0);
$this->elementInfo->expects($this->any())
@@ -290,7 +290,7 @@ class RendererPostRenderCacheTest extends RendererTestBase {
public function testRenderChildrenPostRenderCacheComplex() {
$this->setUpRequest();
$this->setupMemoryCache();
- $this->cacheContexts->expects($this->any())
+ $this->cacheContextsManager->expects($this->any())
->method('convertTokensToKeys')
->willReturnArgument(0);
$this->elementInfo->expects($this->any())
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
index 7f24130..c433e30 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
@@ -40,7 +40,7 @@ class RendererTestBase extends UnitTestCase {
protected $cacheFactory;
/**
- * @var \Drupal\Core\Cache\CacheContexts|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Drupal\Core\Cache\CacheContextsManager|\PHPUnit_Framework_MockObject_MockObject
*/
protected $cacheContexts;
@@ -93,10 +93,10 @@ class RendererTestBase extends UnitTestCase {
$this->elementInfo = $this->getMock('Drupal\Core\Render\ElementInfoManagerInterface');
$this->requestStack = new RequestStack();
$this->cacheFactory = $this->getMock('Drupal\Core\Cache\CacheFactoryInterface');
- $this->cacheContexts = $this->getMockBuilder('Drupal\Core\Cache\CacheContexts')
+ $this->cacheContextsManager = $this->getMockBuilder('Drupal\Core\Cache\CacheContextsManager')
->disableOriginalConstructor()
->getMock();
- $this->cacheContexts->expects($this->any())
+ $this->cacheContextsManager->expects($this->any())
->method('convertTokensToKeys')
->willReturnCallback(function($context_tokens) {
global $current_user_role;
@@ -118,10 +118,10 @@ class RendererTestBase extends UnitTestCase {
}
return $keys;
});
- $this->renderer = new Renderer($this->controllerResolver, $this->themeManager, $this->elementInfo, $this->requestStack, $this->cacheFactory, $this->cacheContexts, $this->rendererConfig);
+ $this->renderer = new Renderer($this->controllerResolver, $this->themeManager, $this->elementInfo, $this->requestStack, $this->cacheFactory, $this->cacheContextsManager, $this->rendererConfig);
$container = new ContainerBuilder();
- $container->set('cache_contexts', $this->cacheContexts);
+ $container->set('cache_contexts_manager', $this->cacheContextsManager);
$container->set('renderer', $this->renderer);
\Drupal::setContainer($container);
}