You are here

public function ActiveWorkspaceCheckTest::testAccess in Drupal 9

Same name and namespace in other branches
  1. 8 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 62

Class

ActiveWorkspaceCheckTest
@coversDefaultClass \Drupal\workspaces\Access\ActiveWorkspaceCheck

Namespace

Drupal\Tests\workspaces\Unit

Code

public function testAccess($requirements, $has_active_workspace, $access, array $contexts = []) {
  $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));
}