function CacheContextsManagerTest::getMockContainer

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::getMockContainer()
  2. 8.9.x core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::getMockContainer()
  3. 10 core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::getMockContainer()
5 calls to CacheContextsManagerTest::getMockContainer()
CacheContextsManagerTest::testAvailableContextLabels in core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php
CacheContextsManagerTest::testAvailableContextStrings in core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php
CacheContextsManagerTest::testConvertTokensToKeys in core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php
@covers ::convertTokensToKeys
CacheContextsManagerTest::testInvalidCalculatedContext in core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php
@covers ::convertTokensToKeys
CacheContextsManagerTest::testInvalidContext in core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php
@covers ::convertTokensToKeys

File

core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php, line 177

Class

CacheContextsManagerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Cache%21Context%21CacheContextsManager.php/class/CacheContextsManager/11.x" title="Converts cache context tokens into cache keys." class="local">\Drupal\Core\Cache\Context\CacheContextsManager</a> @group Cache

Namespace

Drupal\Tests\Core\Cache\Context

Code

protected function getMockContainer() {
    $container = $this->getMockBuilder('Drupal\\Core\\DependencyInjection\\Container')
        ->disableOriginalConstructor()
        ->getMock();
    $container->expects($this->any())
        ->method('get')
        ->willReturnMap([
        [
            'cache_context.foo',
            Container::EXCEPTION_ON_INVALID_REFERENCE,
            new FooCacheContext(),
        ],
        [
            'cache_context.baz',
            Container::EXCEPTION_ON_INVALID_REFERENCE,
            new BazCacheContext(),
        ],
    ]);
    return $container;
}

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