function WorkflowStateTransitionOperationsAccessCheckTest::testMissingRouteParams

Same name in other branches
  1. 8.9.x core/modules/workflows/tests/src/Unit/WorkflowStateTransitionOperationsAccessCheckTest.php \Drupal\Tests\workflows\Unit\WorkflowStateTransitionOperationsAccessCheckTest::testMissingRouteParams()
  2. 10 core/modules/workflows/tests/src/Unit/WorkflowStateTransitionOperationsAccessCheckTest.php \Drupal\Tests\workflows\Unit\WorkflowStateTransitionOperationsAccessCheckTest::testMissingRouteParams()
  3. 11.x 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()));
}

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