You are here

public function ForcePasswordChangeServiceTest::testGetNonPendingUsersForRole in Force Password Change 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Unit/Service/ForcePasswordChangeServiceTest.php \Drupal\Tests\force_password_change\Unit\Service\ForcePasswordChangeServiceTest::testGetNonPendingUsersForRole()

* @covers ::getNonPendingUsersForRole

File

tests/src/Unit/Service/ForcePasswordChangeServiceTest.php, line 305

Class

ForcePasswordChangeServiceTest
@coversDefaultClass \Drupal\force_password_change\Service\ForcePasswordChangeService @group force_password_change

Namespace

Drupal\Tests\force_password_change\Unit\Service

Code

public function testGetNonPendingUsersForRole() {
  $this->mapper
    ->expects($this
    ->at(0))
    ->method('getNonPendingUserIds')
    ->with(FALSE)
    ->willReturn([
    1,
    2,
    3,
  ]);
  $rid = 'authenticated';
  $value = $this->forcePasswordChangeService
    ->getNonPendingUsersForRole($rid, TRUE);
  $this
    ->assertCount(3, $value, 'The correct number of non-pending users was returned for the authenticated role');
  $this->mapper
    ->expects($this
    ->at(0))
    ->method('getNonPendingUserIds')
    ->with('admin')
    ->willReturn([
    1,
    2,
    3,
    4,
  ]);
  $rid = 'admin';
  $value = $this->forcePasswordChangeService
    ->getNonPendingUsersForRole($rid, TRUE);
  $this
    ->assertCount(4, $value, 'The correct number of non-pending users was returned for the admin role');
}