function BlockContentAccessHandlerTest::providerTestAccess
Same name in other branches
- 9 core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php \Drupal\Tests\block_content\Kernel\BlockContentAccessHandlerTest::providerTestAccess()
- 8.9.x core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php \Drupal\Tests\block_content\Kernel\BlockContentAccessHandlerTest::providerTestAccess()
- 10 core/modules/block_content/tests/src/Kernel/BlockContentAccessHandlerTest.php \Drupal\Tests\block_content\Kernel\BlockContentAccessHandlerTest::providerTestAccess()
Data provider for testAccess().
File
-
core/
modules/ block_content/ tests/ src/ Kernel/ BlockContentAccessHandlerTest.php, line 195
Class
- BlockContentAccessHandlerTest
- Tests the block content entity access handler.
Namespace
Drupal\Tests\block_content\KernelCode
public static function providerTestAccess() : array {
$cases = [
'view:published:reusable' => [
'view',
TRUE,
TRUE,
[],
TRUE,
NULL,
AccessResultAllowed::class,
],
'view:unpublished:reusable' => [
'view',
FALSE,
TRUE,
[],
TRUE,
NULL,
AccessResultNeutral::class,
],
'view:unpublished:reusable:admin' => [
'view',
FALSE,
TRUE,
[
'access block library',
],
TRUE,
NULL,
AccessResultAllowed::class,
],
'view:unpublished:reusable:per-block-editor:basic' => [
'view',
FALSE,
TRUE,
[
'edit any basic block content',
],
TRUE,
NULL,
AccessResultNeutral::class,
],
'view:unpublished:reusable:per-block-editor:square' => [
'view',
FALSE,
TRUE,
[
'access block library',
'edit any basic block content',
],
TRUE,
NULL,
AccessResultAllowed::class,
],
'view:published:reusable:admin' => [
'view',
TRUE,
TRUE,
[
'access block library',
],
TRUE,
NULL,
AccessResultAllowed::class,
],
'view:published:reusable:per-block-editor:basic' => [
'view',
TRUE,
TRUE,
[
'access block library',
'edit any basic block content',
],
TRUE,
NULL,
AccessResultAllowed::class,
],
'view:published:reusable:per-block-editor:square' => [
'view',
TRUE,
TRUE,
[
'access block library',
'edit any square block content',
],
TRUE,
NULL,
AccessResultAllowed::class,
],
'view:published:non_reusable' => [
'view',
TRUE,
FALSE,
[],
TRUE,
NULL,
AccessResultForbidden::class,
],
'view:published:non_reusable:parent_allowed' => [
'view',
TRUE,
FALSE,
[],
TRUE,
AccessResultAllowed::class,
AccessResultAllowed::class,
],
'view:published:non_reusable:parent_neutral' => [
'view',
TRUE,
FALSE,
[],
TRUE,
AccessResultNeutral::class,
AccessResultNeutral::class,
],
'view:published:non_reusable:parent_forbidden' => [
'view',
TRUE,
FALSE,
[],
TRUE,
AccessResultForbidden::class,
AccessResultForbidden::class,
],
];
foreach ([
'update',
'delete',
] as $operation) {
$label = $operation === 'update' ? 'edit' : 'delete';
$cases += [
$operation . ':published:reusable' => [
$operation,
TRUE,
TRUE,
[],
TRUE,
NULL,
AccessResultNeutral::class,
],
$operation . ':unpublished:reusable' => [
$operation,
FALSE,
TRUE,
[],
TRUE,
NULL,
AccessResultNeutral::class,
],
$operation . ':unpublished:reusable:admin' => [
$operation,
FALSE,
TRUE,
[
$label . ' any square block content',
],
TRUE,
NULL,
AccessResultAllowed::class,
],
$operation . ':published:reusable:admin' => [
$operation,
TRUE,
TRUE,
[
$label . ' any square block content',
],
TRUE,
NULL,
AccessResultAllowed::class,
],
$operation . ':published:non_reusable' => [
$operation,
TRUE,
FALSE,
[],
TRUE,
NULL,
AccessResultForbidden::class,
],
$operation . ':published:non_reusable:parent_allowed' => [
$operation,
TRUE,
FALSE,
[],
TRUE,
AccessResultAllowed::class,
AccessResultNeutral::class,
],
$operation . ':published:non_reusable:parent_neutral' => [
$operation,
TRUE,
FALSE,
[],
TRUE,
AccessResultNeutral::class,
AccessResultNeutral::class,
],
$operation . ':published:non_reusable:parent_forbidden' => [
$operation,
TRUE,
FALSE,
[],
TRUE,
AccessResultForbidden::class,
AccessResultForbidden::class,
],
$operation . ':unpublished:reusable:per-block-editor:basic' => [
$operation,
FALSE,
TRUE,
[
'edit any basic block content',
],
TRUE,
NULL,
AccessResultNeutral::class,
],
$operation . ':published:reusable:per-block-editor:basic' => [
$operation,
TRUE,
TRUE,
[
'edit any basic block content',
],
TRUE,
NULL,
AccessResultNeutral::class,
],
];
}
$cases += [
'update:unpublished:reusable:per-block-editor:square' => [
'update',
FALSE,
TRUE,
[
'edit any square block content',
],
TRUE,
NULL,
AccessResultAllowed::class,
],
'update:published:reusable:per-block-editor:square' => [
'update',
TRUE,
TRUE,
[
'edit any square block content',
],
TRUE,
NULL,
AccessResultAllowed::class,
],
];
$cases += [
'delete:unpublished:reusable:per-block-editor:square' => [
'delete',
FALSE,
TRUE,
[
'edit any square block content',
],
TRUE,
NULL,
AccessResultNeutral::class,
],
'delete:published:reusable:per-block-editor:square' => [
'delete',
TRUE,
TRUE,
[
'edit any square block content',
],
TRUE,
NULL,
AccessResultNeutral::class,
],
];
// View all revisions:
$cases['view all revisions:none'] = [
'view all revisions',
TRUE,
TRUE,
[],
TRUE,
NULL,
AccessResultNeutral::class,
];
$cases['view all revisions:view any bundle history'] = [
'view all revisions',
TRUE,
TRUE,
[
'view any square block content history',
],
TRUE,
NULL,
AccessResultAllowed::class,
];
$cases['view all revisions:administer block content'] = [
'view all revisions',
TRUE,
TRUE,
[
'administer block content',
],
TRUE,
NULL,
AccessResultAllowed::class,
];
// Revert revisions:
$cases['revert:none:latest'] = [
'revert',
TRUE,
TRUE,
[],
TRUE,
NULL,
AccessResultForbidden::class,
];
$cases['revert:none:historical'] = [
'revert',
TRUE,
TRUE,
[],
FALSE,
NULL,
AccessResultNeutral::class,
];
$cases['revert:revert bundle:historical'] = [
'revert',
TRUE,
TRUE,
[
'revert any square block content revisions',
],
FALSE,
NULL,
AccessResultAllowed::class,
];
$cases['revert:administer block content:latest'] = [
'revert',
TRUE,
TRUE,
[
'administer block content',
],
TRUE,
NULL,
AccessResultForbidden::class,
];
$cases['revert:administer block content:historical'] = [
'revert',
TRUE,
TRUE,
[
'administer block content',
],
FALSE,
NULL,
AccessResultAllowed::class,
];
$cases['revert:revert bundle:historical:non reusable'] = [
'revert',
TRUE,
FALSE,
[
'revert any square block content revisions',
],
FALSE,
NULL,
AccessResultForbidden::class,
'Block content must be reusable to use `revert` operation',
];
// Delete revisions:
$cases['delete revision:none:latest'] = [
'delete revision',
TRUE,
TRUE,
[],
TRUE,
NULL,
AccessResultForbidden::class,
];
$cases['delete revision:none:historical'] = [
'delete revision',
TRUE,
TRUE,
[],
FALSE,
NULL,
AccessResultNeutral::class,
];
$cases['delete revision:administer block content:latest'] = [
'delete revision',
TRUE,
TRUE,
[
'administer block content',
],
TRUE,
NULL,
AccessResultForbidden::class,
];
$cases['delete revision:administer block content:historical'] = [
'delete revision',
TRUE,
TRUE,
[
'administer block content',
],
FALSE,
NULL,
AccessResultAllowed::class,
];
$cases['delete revision:delete bundle:latest'] = [
'delete revision',
TRUE,
TRUE,
[
'administer block content',
],
TRUE,
NULL,
AccessResultForbidden::class,
];
$cases['delete revision:delete bundle:historical'] = [
'delete revision',
TRUE,
TRUE,
[
'delete any square block content revisions',
],
FALSE,
NULL,
AccessResultAllowed::class,
];
$cases['delete revision:delete bundle:historical:non reusable'] = [
'delete revision',
TRUE,
FALSE,
[
'delete any square block content revisions',
],
FALSE,
NULL,
AccessResultForbidden::class,
'Block content must be reusable to use `delete revision` operation',
];
return $cases;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.