protected function RngTestTrait::createUserRoleRules in RNG - Events and Registrations 3.x
Same name and namespace in other branches
- 8.2 src/Tests/RngTestTrait.php \Drupal\rng\Tests\RngTestTrait::createUserRoleRules()
- 8 src/Tests/RngTestTrait.php \Drupal\rng\Tests\RngTestTrait::createUserRoleRules()
Create rules for an event type.
Parameters
array $roles: An array of role ID to add access.
array $operations: An array of operations. Value is boolean whether to grant, key can be any of 'create', 'view', 'update', 'delete'.
9 calls to RngTestTrait::createUserRoleRules()
- RngRegistrationAccessTest::testRegisterSelf in tests/
src/ Kernel/ RngRegistrationAccessTest.php - Test register self.
- RngRegistrationAccessTest::testRegisterSelfNoDuplicates in tests/
src/ Kernel/ RngRegistrationAccessTest.php - Test register self no duplicates.
- RngRegistrationAccessTest::testRegisterSelfNoPermission in tests/
src/ Kernel/ RngRegistrationAccessTest.php - Test register self no permission.
- RngRegistrationAccessTest::testRegisterSelfRuleNoRoles in tests/
src/ Kernel/ RngRegistrationAccessTest.php - Test register self rule with no roles.
- RngRegistrationAccessTest::testRegisterSelfRuleRoleAlternative in tests/
src/ Kernel/ RngRegistrationAccessTest.php - Test register self rule a role the user does not have.
File
- src/
Tests/ RngTestTrait.php, line 111
Class
Namespace
Drupal\rng\TestsCode
protected function createUserRoleRules($roles = [], $operations = []) {
$rule = EventTypeRule::create([
'trigger' => 'rng_event.register',
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
'machine_name' => 'user_role',
]);
$rule
->setCondition('role', [
'id' => 'rng_user_role',
'roles' => $roles,
]);
$rule
->setAction('registration_operations', [
'id' => 'registration_operations',
'configuration' => [
'operations' => $operations,
],
]);
$rule
->save();
}