You are here

public function OgRoleManagerTest::testRoleRemoval in Organic groups 8

Tests role removal.

@covers ::removeRoles

File

tests/src/Unit/OgRoleManagerTest.php, line 202

Class

OgRoleManagerTest
Tests create membership helper function.

Namespace

Drupal\Tests\og\Unit

Code

public function testRoleRemoval() {
  $properties = [
    'group_type' => $this->entityTypeId,
    'group_bundle' => $this->bundle,
  ];
  $this->ogRoleStorage
    ->loadByProperties($properties)
    ->willReturn([
    $this->ogRole
      ->reveal(),
    $this->ogRole
      ->reveal(),
    $this->ogRole
      ->reveal(),
  ])
    ->shouldBeCalled();

  // It is expected that all roles will be deleted, so three delete() calls
  // will be made.
  $this->ogRole
    ->delete()
    ->shouldBeCalledTimes(3);
  $og_role_manager = $this
    ->getOgRoleManager();
  $og_role_manager
    ->removeRoles($this->entityTypeId, $this->bundle);
}