You are here

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

* @covers ::getRoleExpiryTimePeriods

File

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

Class

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

Namespace

Drupal\Tests\force_password_change\Unit\Service

Code

public function testgetRoleExpiryTimePeriods() {
  $this->mapper
    ->expects($this
    ->at(0))
    ->method('getRoleExpiryTimePeriods')
    ->willReturn([
    'authenticated' => 1,
    'admin' => 2,
  ]);
  $value = $this->forcePasswordChangeService
    ->getRoleExpiryTimePeriods();
  $this
    ->assertArrayHasKey('authenticated', $value, 'The authenticated key exists in the list of role expiry dates');
  $this
    ->assertEquals(1, $value['authenticated'], 'The expiration value for the authenticated user is correct');
  $this
    ->assertArrayHasKey('admin', $value, 'The authenticated key exists in the list of role expiry dates');
  $this
    ->assertEquals(2, $value['admin'], 'The expiration value for the admin user is correct');
}