public function DefaultRoleEventTest::testAddRole in Organic groups 8
Tests adding an OG role to the default role event.
@covers ::addRole
@dataProvider defaultRoleProvider
Parameters
array $roles: An array of test default roles.
File
- tests/
src/ Unit/ DefaultRoleEventTest.php, line 102
Class
- DefaultRoleEventTest
- Tests default role events.
Namespace
Drupal\Tests\og\UnitCode
public function testAddRole(array $roles) {
$this
->expectOgRoleCreation($roles);
foreach ($roles as $name => $role) {
$this
->assertFalse($this->defaultRoleEvent
->hasRole($name));
$this->defaultRoleEvent
->addRole($role);
$this
->assertRoleEquals($role, $this->defaultRoleEvent
->getRole($name));
// Adding a role a second time should throw an exception.
try {
$this->defaultRoleEvent
->addRole($role);
$this
->fail('It should not be possible to add a role with the same name a second time.');
} catch (\InvalidArgumentException $e) {
// Expected result.
}
}
}