function WorkflowStateTransitionOperationsAccessCheckTest::testMissingRouteParams

Tests missing route params.

@legacy-covers ::access

File

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

Class

WorkflowStateTransitionOperationsAccessCheckTest
Tests Drupal\workflows\WorkflowStateTransitionOperationsAccessCheck.

Namespace

Drupal\Tests\workflows\Unit

Code

public function testMissingRouteParams() : void {
  $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()));
}

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