You are here

public function CacheContextsManagerTest::testValidateContexts in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest::testValidateContexts()

@covers ::validateTokens

@dataProvider validateTokensProvider

File

core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php, line 236
Contains \Drupal\Tests\Core\Cache\Context\CacheContextsManagerTest.

Class

CacheContextsManagerTest
@coversDefaultClass \Drupal\Core\Cache\Context\CacheContextsManager @group Cache

Namespace

Drupal\Tests\Core\Cache\Context

Code

public function testValidateContexts(array $contexts, $expected_exception_message) {
  $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));
}