function ActiveWorkspaceCheckTest::testAccess

Same name in other branches
  1. 9 core/modules/workspaces/tests/src/Unit/ActiveWorkspaceCheckTest.php \Drupal\Tests\workspaces\Unit\ActiveWorkspaceCheckTest::testAccess()
  2. 8.9.x core/modules/workspaces/tests/src/Unit/ActiveWorkspaceCheckTest.php \Drupal\Tests\workspaces\Unit\ActiveWorkspaceCheckTest::testAccess()
  3. 11.x core/modules/workspaces/tests/src/Unit/ActiveWorkspaceCheckTest.php \Drupal\Tests\workspaces\Unit\ActiveWorkspaceCheckTest::testAccess()

@covers ::access @dataProvider providerTestAccess

File

core/modules/workspaces/tests/src/Unit/ActiveWorkspaceCheckTest.php, line 64

Class

ActiveWorkspaceCheckTest
@coversDefaultClass \Drupal\workspaces\Access\ActiveWorkspaceCheck

Namespace

Drupal\Tests\workspaces\Unit

Code

public function testAccess($requirements, $has_active_workspace, $access, array $contexts = []) : void {
    $route = new Route('', [], $requirements);
    $workspace_manager = $this->prophesize(WorkspaceManagerInterface::class);
    $workspace_manager->hasActiveWorkspace()
        ->willReturn($has_active_workspace);
    $access_check = new ActiveWorkspaceCheck($workspace_manager->reveal());
    $access_result = AccessResult::allowedIf($access)->addCacheContexts($contexts);
    $this->assertEquals($access_result, $access_check->access($route));
}

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