function UserRolesAccessPolicyTest::setUp

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Session/UserRolesAccessPolicyTest.php, line 44

Class

UserRolesAccessPolicyTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Session%21UserRolesAccessPolicy.php/class/UserRolesAccessPolicy/11.x" title="Grants permissions based on a user&#039;s roles." class="local">\Drupal\Core\Session\UserRolesAccessPolicy</a> @group Session

Namespace

Drupal\Tests\Core\Session

Code

protected function setUp() : void {
    parent::setUp();
    $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class);
    $this->accessPolicy = new UserRolesAccessPolicy($this->entityTypeManager
        ->reveal());
    $cache_context_manager = $this->prophesize(CacheContextsManager::class);
    $cache_context_manager->assertValidTokens(Argument::any())
        ->willReturn(TRUE);
    $container = $this->prophesize(ContainerInterface::class);
    $container->get('cache_contexts_manager')
        ->willReturn($cache_context_manager->reveal());
    \Drupal::setContainer($container->reveal());
}

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