public function OgGroupContentOperationAccessTest::testAccess in Organic groups 8
Test access to group content entity operations.
@dataProvider accessProvider
File
- tests/
src/ Kernel/ Access/ OgGroupContentOperationAccessTest.php, line 258
Class
- OgGroupContentOperationAccessTest
- Test access to group content operations for group members.
Namespace
Drupal\Tests\og\Kernel\AccessCode
public function testAccess($group_content_bundle_id, $expected_access_matrix) {
/** @var \Drupal\og\OgAccessInterface $og_access */
$og_access = $this->container
->get('og.access');
foreach ($expected_access_matrix as $user_id => $operations) {
foreach ($operations as $operation => $ownerships) {
foreach ($ownerships as $ownership => $expected_access) {
// Depending on whether we're testing access to a user's own entity,
// use either the entity owned by the user, or the one used by the
// group owner.
$entity = $ownership === 'own' ? $this->groupContent[$group_content_bundle_id][$user_id] : $this->groupContent[$group_content_bundle_id]['group_owner'];
$user = $this->users[$user_id];
$this
->assertEquals($expected_access, $og_access
->userAccessEntityOperation($operation, $entity, $user)
->isAllowed(), "Operation: {$operation}, ownership: {$ownership}, user: {$user_id}, bundle: {$group_content_bundle_id}");
}
}
}
}