public function WorkflowAccessControlHandlerTest::testCheckAccess in Drupal 9
Same name and namespace in other branches
- 8 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 105
Class
- WorkflowAccessControlHandlerTest
- @coversDefaultClass \Drupal\workflows\WorkflowAccessControlHandler @group workflows
Namespace
Drupal\Tests\workflows\KernelCode
public function testCheckAccess($user, $operation, $result, $states_to_create = []) {
$workflow = Workflow::create([
'type' => 'workflow_type_test',
'id' => '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));
}