function WorkflowStateTransitionOperationsAccessCheckTest::testAccess

Same name in other branches
  1. 8.9.x 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()
  3. 11.x 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()));
}

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