protected function RESTTestBase::entityPermissions in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/rest/src/Tests/RESTTestBase.php \Drupal\rest\Tests\RESTTestBase::entityPermissions()
Provides the necessary user permissions for entity operations.
Parameters
string $entity_type: The entity type.
string $operation: The operation, one of 'view', 'create', 'update' or 'delete'.
Return value
array The set of user permission strings.
13 calls to RESTTestBase::entityPermissions()
- AuthTest::testRead in core/
modules/ rest/ src/ Tests/ AuthTest.php - Tests reading from an authenticated resource.
- CreateTest::createAccountPerEntity in core/
modules/ rest/ src/ Tests/ CreateTest.php - Creates user accounts that have the required permissions to create resources via the REST API. The second one has administrative permissions.
- CreateTest::testCreateResourceRestApiNotEnabled in core/
modules/ rest/ src/ Tests/ CreateTest.php - Try to create a resource which is not REST API enabled.
- CreateTest::testCreateWithoutPermission in core/
modules/ rest/ src/ Tests/ CreateTest.php - Ensure that an entity cannot be created without the restful permission.
- CsrfTest::setUp in core/
modules/ rest/ src/ Tests/ CsrfTest.php - Sets up a Drupal site for running functional and integration tests.
File
- core/
modules/ rest/ src/ Tests/ RESTTestBase.php, line 309 - Contains \Drupal\rest\Tests\RESTTestBase.
Class
- RESTTestBase
- Test helper class that provides a REST client method to send HTTP requests.
Namespace
Drupal\rest\TestsCode
protected function entityPermissions($entity_type, $operation) {
switch ($entity_type) {
case 'entity_test':
switch ($operation) {
case 'view':
return array(
'view test entity',
);
case 'create':
case 'update':
case 'delete':
return array(
'administer entity_test content',
);
}
case 'node':
switch ($operation) {
case 'view':
return array(
'access content',
);
case 'create':
return array(
'create resttest content',
);
case 'update':
return array(
'edit any resttest content',
);
case 'delete':
return array(
'delete any resttest content',
);
}
case 'comment':
switch ($operation) {
case 'view':
return [
'access comments',
];
case 'create':
return [
'post comments',
'skip comment approval',
];
case 'update':
return [
'edit own comments',
];
case 'delete':
return [
'administer comments',
];
}
break;
case 'user':
switch ($operation) {
case 'view':
return [
'access user profiles',
];
default:
return [
'administer users',
];
}
}
}