public function WorkflowAccessControlHandlerTest::checkAccessProvider in Drupal 10
Same name and namespace in other branches
- 8 core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php \Drupal\Tests\workflows\Kernel\WorkflowAccessControlHandlerTest::checkAccessProvider()
- 9 core/modules/workflows/tests/src/Kernel/WorkflowAccessControlHandlerTest.php \Drupal\Tests\workflows\Kernel\WorkflowAccessControlHandlerTest::checkAccessProvider()
Data provider for ::testCheckAccess.
Return value
array
File
- core/
modules/ workflows/ tests/ src/ Kernel/ WorkflowAccessControlHandlerTest.php, line 124
Class
- WorkflowAccessControlHandlerTest
- @coversDefaultClass \Drupal\workflows\WorkflowAccessControlHandler @group workflows
Namespace
Drupal\Tests\workflows\KernelCode
public function checkAccessProvider() {
$container = new ContainerBuilder();
$cache_contexts_manager = $this
->prophesize(CacheContextsManager::class);
$cache_contexts_manager
->assertValidTokens()
->willReturn(TRUE);
$cache_contexts_manager
->reveal();
$container
->set('cache_contexts_manager', $cache_contexts_manager);
\Drupal::setContainer($container);
return [
'Admin view' => [
'adminUser',
'view',
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
'Admin update' => [
'adminUser',
'update',
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
'Admin delete' => [
'adminUser',
'delete',
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
'Admin delete only state' => [
'adminUser',
'delete-state:foo',
AccessResult::neutral()
->addCacheTags([
'config:workflows.workflow.test_workflow',
]),
[
'foo' => FALSE,
],
],
'Admin delete one of two states' => [
'adminUser',
'delete-state:foo',
AccessResult::allowed()
->addCacheTags([
'config:workflows.workflow.test_workflow',
])
->addCacheContexts([
'user.permissions',
]),
[
'foo' => FALSE,
'bar' => FALSE,
],
],
'Admin delete required state when there are >1 states' => [
'adminUser',
'delete-state:foo',
AccessResult::allowed()
->addCacheTags([
'config:workflows.workflow.test_workflow',
])
->addCacheContexts([
'user.permissions',
]),
[
'foo' => TRUE,
'bar' => FALSE,
],
],
'User view' => [
'user',
'view',
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer workflows' permission is required."),
],
'User update' => [
'user',
'update',
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer workflows' permission is required."),
],
'User delete' => [
'user',
'delete',
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer workflows' permission is required."),
],
'User delete only state' => [
'user',
'delete-state:foo',
AccessResult::neutral()
->addCacheTags([
'config:workflows.workflow.test_workflow',
]),
[
'foo' => FALSE,
],
],
'User delete one of two states' => [
'user',
'delete-state:foo',
AccessResult::neutral()
->addCacheTags([
'config:workflows.workflow.test_workflow',
])
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer workflows' permission is required."),
[
'foo' => FALSE,
'bar' => FALSE,
],
],
'User delete required state when there are >1 states' => [
'user',
'delete-state:foo',
AccessResult::neutral()
->addCacheTags([
'config:workflows.workflow.test_workflow',
])
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer workflows' permission is required."),
[
'foo' => TRUE,
'bar' => FALSE,
],
],
'Update state for user, uses admin permission by default' => [
'user',
'update-state:foo',
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer workflows' permission is required."),
],
'Update state for admin, uses admin permission by default' => [
'adminUser',
'update-state:foo',
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
'Add state for user, uses admin permission by default' => [
'user',
'add-state',
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer workflows' permission is required."),
],
'Add state for admin, uses admin permission by default' => [
'adminUser',
'add-state',
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
'Add transition for user, uses admin permission by default' => [
'user',
'add-transition',
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer workflows' permission is required."),
],
'Add transition for admin, uses admin permission by default' => [
'adminUser',
'add-transition',
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
'Edit transition for user, uses admin permission by default' => [
'user',
'edit-transition:foo',
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer workflows' permission is required."),
],
'Edit transition for admin, uses admin permission by default' => [
'adminUser',
'edit-transition:foo',
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
'Delete transition for user, uses admin permission by default' => [
'user',
'delete-transition:foo',
AccessResult::neutral()
->addCacheContexts([
'user.permissions',
])
->setReason("The 'administer workflows' permission is required."),
],
'Delete transition for admin, uses admin permission by default' => [
'adminUser',
'delete-transition:foo',
AccessResult::allowed()
->addCacheContexts([
'user.permissions',
]),
],
];
}