function TokenTest::setUp

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Utility/TokenTest.php \Drupal\Tests\Core\Utility\TokenTest::setUp()
  2. 8.9.x core/tests/Drupal/Tests/Core/Utility/TokenTest.php \Drupal\Tests\Core\Utility\TokenTest::setUp()
  3. 11.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 81

Class

TokenTest
@coversDefaultClass \Drupal\Core\Utility\Token @group Utility

Namespace

Drupal\Tests\Core\Utility

Code

protected function setUp() : void {
    parent::setUp();
    $this->cache = $this->createMock('\\Drupal\\Core\\Cache\\CacheBackendInterface');
    $this->languageManager = $this->createMock('Drupal\\Core\\Language\\LanguageManagerInterface');
    $this->moduleHandler = $this->createMock('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
    $this->language = $this->createMock('\\Drupal\\Core\\Language\\LanguageInterface');
    $this->cacheTagsInvalidator = $this->createMock('\\Drupal\\Core\\Cache\\CacheTagsInvalidatorInterface');
    $this->renderer = $this->createMock('Drupal\\Core\\Render\\RendererInterface');
    $this->token = new Token($this->moduleHandler, $this->cache, $this->languageManager, $this->cacheTagsInvalidator, $this->renderer);
    $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.