public function GroupContentPermissionProviderTest::testGetPermission in Group 8
Tests the permission name getter.
@covers ::getPermission @dataProvider getPermissionProvider
Parameters
string $plugin_id: The plugin ID.
array $definition: The plugin definition.
bool $implements_owner: Whether the plugin's entity type deals with ownership.
bool $implements_published: Whether the plugin's entity type deals with publishing of entities.
string $operation: The $operation parameter for the tested method.
string $target: The $target parameter for the tested method.
string $scope: The $scope parameter for the tested method.
File
- tests/
src/ Unit/ GroupContentPermissionProviderTest.php, line 487
Class
- GroupContentPermissionProviderTest
- Tests the default GroupContentEnabler permission_provider handler.
Namespace
Drupal\Tests\group\UnitCode
public function testGetPermission($plugin_id, array $definition, $implements_owner, $implements_published, $operation, $target, $scope) {
$permission_provider = $this
->createPermissionProvider($plugin_id, $definition, $implements_owner, $implements_published);
$expected = FALSE;
if ($target === 'relation') {
switch ($operation) {
case 'view':
$expected = $permission_provider
->getRelationViewPermission($scope);
break;
case 'update':
$expected = $permission_provider
->getRelationUpdatePermission($scope);
break;
case 'delete':
$expected = $permission_provider
->getRelationDeletePermission($scope);
break;
case 'create':
$expected = $permission_provider
->getRelationCreatePermission();
break;
}
}
elseif ($target === 'entity') {
switch ($operation) {
case 'view':
$expected = $permission_provider
->getEntityViewPermission($scope);
break;
case 'view unpublished':
$expected = $permission_provider
->getEntityViewUnpublishedPermission($scope);
break;
case 'update':
$expected = $permission_provider
->getEntityUpdatePermission($scope);
break;
case 'delete':
$expected = $permission_provider
->getEntityDeletePermission($scope);
break;
case 'create':
$expected = $permission_provider
->getEntityCreatePermission();
break;
}
}
$this
->assertEquals($expected, $permission_provider
->getPermission($operation, $target, $scope));
}