function TokenTest::setUp

Same name and namespace 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. 10 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 <a href="/api/drupal/core%21lib%21Drupal%21Core%21Utility%21Token.php/class/Token/11.x" title="Drupal placeholder/token replacement system." class="local">\Drupal\Core\Utility\Token</a> @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.