You are here

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

Overrides UnitTestCase::setUp

File

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

Class

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

Namespace

Drupal\Tests\force_password_change\Unit\Service

Code

public function setUp() {
  $this->mapper = $this
    ->getMockBuilder('\\Drupal\\force_password_change\\Mapper\\ForcePasswordChangeMapperInterface')
    ->disableOriginalConstructor()
    ->getMock();
  $this->mapper
    ->expects($this
    ->any())
    ->method('getUserCreatedTime')
    ->willReturn(1000000);
  $this->currentUser = $this
    ->getMockBuilder('\\Drupal\\Core\\Session\\AccountProxyInterface')
    ->disableOriginalConstructor()
    ->getMock();
  $this->currentUser
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn(1);
  $this->currentUser
    ->expects($this
    ->any())
    ->method('getRoles')
    ->willReturn([
    'authenticated',
  ]);
  $this->configFactory = $this
    ->getMockBuilder('\\Drupal\\Core\\Config\\ConfigFactoryInterface')
    ->disableOriginalConstructor()
    ->getMock();
  $this->userData = $this
    ->getMockBuilder('\\Drupal\\user\\UserDataInterface')
    ->disableOriginalConstructor()
    ->getMock();
  $this->forcePasswordChangeService = new ForcePasswordChangeService($this->mapper, $this->currentUser, $this->configFactory, $this->userData);
}