function TokenTest::setUp

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

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Utility/TokenTest.php, line 83

Class

TokenTest
Tests Drupal\Core\Utility\Token.

Namespace

Drupal\Tests\Core\Utility

Code

protected function setUp() : void {
  parent::setUp();
  $this->cache = $this->createStub(CacheBackendInterface::class);
  $this->languageManager = $this->createStub(LanguageManagerInterface::class);
  $this->moduleHandler = $this->createStub(ModuleHandlerInterface::class);
  $this->language = $this->createStub(LanguageInterface::class);
  $this->cacheTagsInvalidator = $this->createStub(CacheTagsInvalidatorInterface::class);
  $this->token = new Token($this->moduleHandler, $this->cache, $this->languageManager, $this->cacheTagsInvalidator, $this->createStub(RendererInterface::class));
  $container = new ContainerBuilder();
  $this->cacheContextManager = new CacheContextsManager($container, [
    'current_user',
    'custom_context',
  ]);
  $container->set('cache_contexts_manager', $this->cacheContextManager);
  \Drupal::setContainer($container);
}

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