public function PermissionEventTest::testOffsetUnset in Organic groups 8
Tests "offsetUnset".
@covers ::offsetUnset
@dataProvider permissionsProvider
Parameters
\Drupal\og\PermissionInterface[] $permissions: An array of test permissions.
string $entity_type_id: The entity type ID of the group type to which the permissions apply.
string $bundle_id: The bundle ID of the group type to which the permissions apply.
array $group_content_bundle_ids: An array of group content bundle IDs to which the permissions apply, keyed by group content entity type ID.
File
- tests/
src/ Unit/ PermissionEventTest.php, line 515
Class
- PermissionEventTest
- Tests permission events.
Namespace
Drupal\Tests\og\UnitCode
public function testOffsetUnset(array $permissions, $entity_type_id, $bundle_id, array $group_content_bundle_ids) {
$event = new PermissionEvent($entity_type_id, $bundle_id, $group_content_bundle_ids);
$event
->setPermissions($permissions);
foreach ($permissions as $name => $permission) {
$this
->assertTrue($event
->hasPermission($name));
unset($event[$name]);
$this
->assertFalse($event
->hasPermission($name));
}
// Test that it is possible to unset a non-existing permissions. In keeping
// with standard PHP practices this should not throw any error.
unset($event['some-non-existing-permission']);
}