function CacheContextsManagerTest::testConvertTokensToKeys

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::testConvertTokensToKeys()
  2. 10 core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::testConvertTokensToKeys()
  3. 11.x core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::testConvertTokensToKeys()

@covers ::convertTokensToKeys

File

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

Class

CacheContextsManagerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Cache%21Context%21CacheContextsManager.php/class/CacheContextsManager/9" 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

public function testConvertTokensToKeys() {
    $container = $this->getMockContainer();
    $cache_contexts_manager = new CacheContextsManager($container, $this->getContextsFixture());
    $new_keys = $cache_contexts_manager->convertTokensToKeys([
        'foo',
        'baz:parameterA',
        'baz:parameterB',
    ]);
    $expected = [
        '[baz:parameterA]=cnenzrgreN',
        '[baz:parameterB]=cnenzrgreO',
        '[foo]=bar',
    ];
    $this->assertEquals($expected, $new_keys->getKeys());
}

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