You are here

public function WorkflowStateTransitionOperationsAccessCheckTest::testMissingRouteParams 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::testMissingRouteParams()

@covers ::access

File

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

Class

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

Namespace

Drupal\Tests\workflows\Unit

Code

public function testMissingRouteParams() {
  $workflow = $this
    ->prophesize(WorkflowInterface::class);
  $workflow
    ->access()
    ->shouldNotBeCalled();
  $route = new Route('', [
    'workflow' => NULL,
    'workflow_state' => NULL,
  ], [
    '_workflow_access' => 'update-state',
  ]);
  $access_check = new WorkflowStateTransitionOperationsAccessCheck();
  $account = $this
    ->prophesize(AccountInterface::class);
  $missing_both = new RouteMatch(NULL, $route, []);
  $this
    ->assertEquals(AccessResult::neutral(), $access_check
    ->access($missing_both, $account
    ->reveal()));
  $missing_state = new RouteMatch(NULL, $route, [
    'workflow' => $workflow
      ->reveal(),
  ]);
  $this
    ->assertEquals(AccessResult::neutral(), $access_check
    ->access($missing_state, $account
    ->reveal()));
  $missing_workflow = new RouteMatch(NULL, $route, [
    'workflow_state' => 'foo',
  ]);
  $this
    ->assertEquals(AccessResult::neutral(), $access_check
    ->access($missing_workflow, $account
    ->reveal()));
}