You are here

public function DefaultRoleEventTest::testAddInvalidRole in Organic groups 8

Tests adding an invalid OG role to the default role event.

@covers ::addRole

@dataProvider invalidDefaultRoleProvider

Parameters

array $invalid_roles: An array of invalid test default roles.

File

tests/src/Unit/DefaultRoleEventTest.php, line 326

Class

DefaultRoleEventTest
Tests default role events.

Namespace

Drupal\Tests\og\Unit

Code

public function testAddInvalidRole(array $invalid_roles) {
  $this
    ->expectOgRoleCreation($invalid_roles);
  try {
    foreach ($invalid_roles as $invalid_role) {
      $this->defaultRoleEvent
        ->addRole($invalid_role);
    }
    $this
      ->fail('An invalid role cannot be added.');
  } catch (\InvalidArgumentException $e) {

    // Expected result. Do an arbitrary assertion so the test is not marked as
    // risky.
    $this
      ->assertTrue(TRUE);
  }
}