function WorkflowAccessControlHandlerTest::testCheckAccess

Same name in other branches
  1. 9 core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php \Drupal\Tests\workflows\Kernel\WorkflowAccessControlHandlerTest::testCheckAccess()
  2. 8.9.x core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php \Drupal\Tests\workflows\Kernel\WorkflowAccessControlHandlerTest::testCheckAccess()
  3. 11.x core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php \Drupal\Tests\workflows\Kernel\WorkflowAccessControlHandlerTest::testCheckAccess()

@covers ::checkAccess @dataProvider checkAccessProvider

File

core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php, line 104

Class

WorkflowAccessControlHandlerTest
@coversDefaultClass \Drupal\workflows\WorkflowAccessControlHandler @group workflows @group #slow

Namespace

Drupal\Tests\workflows\Kernel

Code

public function testCheckAccess($user, $operation, $result, $states_to_create = []) : void {
    $workflow = Workflow::create([
        'type' => 'workflow_type_test',
        'id' => 'test_workflow',
        'label' => 'Test workflow',
    ]);
    $workflow->save();
    $workflow_type = $workflow->getTypePlugin();
    foreach ($states_to_create as $state_id => $is_required) {
        $workflow_type->addState($state_id, $this->randomString());
    }
    \Drupal::state()->set('workflow_type_test.required_states', array_filter($states_to_create));
    $this->assertEquals($result, $this->accessControlHandler
        ->access($workflow, $operation, $this->{$user}, TRUE));
}

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