public function RequiredByRoleTest::getRequiredCases in Required by role 8
Provides a cases to test.
File
- src/
Tests/ Plugin/ Required/ RequiredByRoleTest.php, line 71 - Contains \Drupal\required_by_role\Tests\Plugin\Required\RequiredByRoleTest.
Class
- RequiredByRoleTest
- Tests the requird_by_role plugin.
Namespace
Drupal\required_by_role\Tests\Plugin\RequiredCode
public function getRequiredCases() {
// array(bool $result, array $user_roles, array $required_roles)
return [
// User with matching roles.
[
TRUE,
[
AccountInterface::AUTHENTICATED_ROLE,
'administrator',
],
[
'administrator',
],
],
// User with no matching roles.
[
FALSE,
[
AccountInterface::AUTHENTICATED_ROLE,
'administrator',
],
[
AccountInterface::ANONYMOUS_ROLE,
],
],
// No required roles set.
[
FALSE,
[
AccountInterface::AUTHENTICATED_ROLE,
'administrator',
],
[],
],
// Required roles is not an array.
[
FALSE,
[
AccountInterface::AUTHENTICATED_ROLE,
'administrator',
],
NULL,
],
// The user has no roles.
[
FALSE,
NULL,
[
AccountInterface::AUTHENTICATED_ROLE,
'administrator',
],
],
// The user has no roles and there is no required roles.
[
FALSE,
NULL,
NULL,
],
];
}