You are here

public function ForcePasswordChangeServiceTest::testGetUserCountForRole 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::testGetUserCountForRole()

* @covers ::getUserCountForRole

File

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

Class

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

Namespace

Drupal\Tests\force_password_change\Unit\Service

Code

public function testGetUserCountForRole() {
  $this->mapper
    ->expects($this
    ->at(0))
    ->method('getUserCountForRole')
    ->with(FALSE)
    ->willReturn(100);
  $rid = 'authenticated';
  $value = $this->forcePasswordChangeService
    ->getUserCountForRole($rid);
  $this
    ->assertEquals(100, $value, 'The user count value is properly returned for the authenticated role');
  $this->mapper
    ->expects($this
    ->at(0))
    ->method('getUserCountForRole')
    ->with('admin')
    ->willReturn(101);
  $rid = 'admin';
  $value = $this->forcePasswordChangeService
    ->getUserCountForRole($rid);
  $this
    ->assertEquals(101, $value, 'The user count value is properly returned for the admin role');
}