You are here

protected function WebformAccessTestBase::setUp in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Unit/Access/WebformAccessTestBase.php \Drupal\Tests\webform\Unit\Access\WebformAccessTestBase::setUp()

Overrides UnitTestCase::setUp

File

tests/src/Unit/Access/WebformAccessTestBase.php, line 23

Class

WebformAccessTestBase
Base class for test access checks.

Namespace

Drupal\Tests\webform\Unit\Access

Code

protected function setUp() {
  parent::setUp();
  $this->container = new ContainerBuilder();
  \Drupal::setContainer($this->container);

  // Mock cache context manager and set container.
  // @copied from \Drupal\Tests\Core\Access\AccessResultTest::setUp
  $cache_contexts_manager = $this
    ->getMockBuilder('Drupal\\Core\\Cache\\Context\\CacheContextsManager')
    ->disableOriginalConstructor()
    ->getMock();
  $cache_contexts_manager
    ->method('assertValidTokens')
    ->willReturn(TRUE);
  $this->container
    ->set('cache_contexts_manager', $cache_contexts_manager);
}