public function PermissionEventTest::groupContentOperationPermissionsProvider in Organic groups 8
Data provider to test group content operation permissions.
Return value
array An array of test data arrays, each test data array containing:
- An array of test permissions, keyed by permission ID.
- The entity type ID of the group type to which these permissions apply.
- The bundle ID of the group type to which these permissions apply.
- An array of group content bundle IDs to which these permissions apply, keyed by group content entity type ID.
File
- tests/
src/ Unit/ PermissionEventTest.php, line 886
Class
- PermissionEventTest
- Tests permission events.
Namespace
Drupal\Tests\og\UnitCode
public function groupContentOperationPermissionsProvider() {
$permissions = [
// A simple permission with only the required parameters.
[
[
new GroupContentOperationPermission([
'name' => 'paint yak wool',
'title' => $this
->t('Paint yak wool'),
'entity type' => 'wool',
'bundle' => 'yak fibre',
'operation' => 'paint',
]),
],
],
// A single permission with restricted access and a default role.
[
[
new GroupContentOperationPermission([
'name' => 'shave any wild yak',
'title' => $this
->t('Shave any wild yaks'),
'description' => $this
->t('Whether the user has the right to shave wild yaks. This is usually limited to administrators since it is more dangerous than shaving domesticated yaks.'),
'entity type' => 'yak',
'bundle' => 'bos mutus',
'operation' => 'shave',
'default roles' => [
OgRoleInterface::ADMINISTRATOR,
],
'restrict access' => TRUE,
]),
],
],
// A permission with an owner.
[
[
new GroupContentOperationPermission([
'name' => 'shave own domesticated yak',
'title' => $this
->t('Shave own domesticated yaks'),
'description' => $this
->t('Whether the user has the right to their own domesticated yaks. This is granted by default to all members since it is expected that everyone knows how to take care of their own yaks.'),
'entity type' => 'yak',
'bundle' => 'bos grunniens',
'operation' => 'shave',
'owner' => TRUE,
'default roles' => [
OgRoleInterface::AUTHENTICATED,
OgRoleInterface::ADMINISTRATOR,
],
]),
],
],
// Simulate a subscriber providing multiple permissions.
[
[
new GroupContentOperationPermission([
'name' => 'spin any yak fibre',
'title' => $this
->t('Spin any yak fibre'),
'entity type' => 'wool',
'bundle' => 'yak fibre',
'operation' => 'spin',
'owner' => TRUE,
]),
new GroupContentOperationPermission([
'name' => 'weave own yak fibre',
'title' => $this
->t('Weave own yak fibre'),
'entity type' => 'wool',
'bundle' => 'yak fibre',
'operation' => 'weave',
'owner' => TRUE,
]),
new GroupContentOperationPermission([
'name' => 'dye any yak fibre',
'title' => $this
->t('Dye any yak fibre'),
'entity type' => 'wool',
'bundle' => 'yak fibre',
'operation' => 'dye',
]),
],
],
];
// Supply a random entity type ID, bundle ID and array of group content
// bundle IDs for each data set.
foreach ($permissions as &$item) {
$item[] = $this
->randomMachineName();
$item[] = $this
->randomMachineName();
$item[] = [
$this
->randomMachineName() => [
$this
->randomMachineName(),
],
];
}
return $permissions;
}