function AccessResultTest::setUp

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::setUp()
  2. 10 core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::setUp()
  3. 11.x core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Access/AccessResultTest.php, line 35

Class

AccessResultTest
@coversDefaultClass \Drupal\Core\Access\AccessResult @group Access

Namespace

Drupal\Tests\Core\Access

Code

protected function setUp() : void {
    parent::setUp();
    $this->cacheContextsManager = $this->getMockBuilder('Drupal\\Core\\Cache\\Context\\CacheContextsManager')
        ->disableOriginalConstructor()
        ->getMock();
    $this->cacheContextsManager
        ->method('assertValidTokens')
        ->willReturn(TRUE);
    $container = new ContainerBuilder();
    $container->set('cache_contexts_manager', $this->cacheContextsManager);
    \Drupal::setContainer($container);
}

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