You are here

public function WorkflowStateTransitionOperationsAccessCheckTest::testAccess in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/workflows/tests/src/Unit/WorkflowStateTransitionOperationsAccessCheckTest.php \Drupal\Tests\workflows\Unit\WorkflowStateTransitionOperationsAccessCheckTest::testAccess()
  2. 10 core/modules/workflows/tests/src/Unit/WorkflowStateTransitionOperationsAccessCheckTest.php \Drupal\Tests\workflows\Unit\WorkflowStateTransitionOperationsAccessCheckTest::testAccess()

Tests the access method correctly proxies to the entity access system.

@covers ::access @dataProvider accessTestCases

File

core/modules/workflows/tests/src/Unit/WorkflowStateTransitionOperationsAccessCheckTest.php, line 26

Class

WorkflowStateTransitionOperationsAccessCheckTest
@coversDefaultClass \Drupal\workflows\WorkflowStateTransitionOperationsAccessCheck @group workflows

Namespace

Drupal\Tests\workflows\Unit

Code

public function testAccess($route_requirement, $resulting_entity_access_check, $route_parameters = []) {
  $workflow_entity_access_result = AccessResult::allowed();
  $workflow = $this
    ->prophesize(WorkflowInterface::class);
  $workflow
    ->access($resulting_entity_access_check, Argument::type(AccountInterface::class), TRUE)
    ->shouldBeCalled()
    ->willReturn($workflow_entity_access_result);
  $route = new Route('', [
    'workflow' => NULL,
    'workflow_transition' => NULL,
    'workflow_state' => NULL,
  ], [
    '_workflow_access' => $route_requirement,
  ]);
  $route_match_params = [
    'workflow' => $workflow
      ->reveal(),
  ] + $route_parameters;
  $route_match = new RouteMatch(NULL, $route, $route_match_params);
  $access_check = new WorkflowStateTransitionOperationsAccessCheck();
  $account = $this
    ->prophesize(AccountInterface::class);
  $this
    ->assertEquals($workflow_entity_access_result, $access_check
    ->access($route_match, $account
    ->reveal()));
}