function CacheContextsManagerTest::testValidateContexts

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

Tests validate contexts.

@legacy-covers ::validateTokens

Attributes

#[DataProvider('validateTokensProvider')]

File

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

Class

CacheContextsManagerTest
Tests Drupal\Core\Cache\Context\CacheContextsManager.

Namespace

Drupal\Tests\Core\Cache\Context

Code

public function testValidateContexts(array $contexts, $expected_exception_message) : void {
  $container = new ContainerBuilder();
  $cache_contexts_manager = new CacheContextsManager($container, [
    'foo',
    'foo.bar',
    'baz',
  ]);
  if ($expected_exception_message !== FALSE) {
    $this->expectException('LogicException');
    $this->expectExceptionMessage($expected_exception_message);
  }
  // If it doesn't throw an exception, validateTokens() returns NULL.
  $this->assertNull($cache_contexts_manager->validateTokens($contexts));
}

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