public function ForcePasswordChangeServiceTest::setUp in Force Password Change 2.0.x
Same name and namespace in other branches
- 8 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 50  
Class
- ForcePasswordChangeServiceTest
 - @coversDefaultClass \Drupal\force_password_change\Service\ForcePasswordChangeService @group force_password_change
 
Namespace
Drupal\Tests\force_password_change\Unit\ServiceCode
public function setUp() : void {
  $this->container = new ContainerBuilder();
  \Drupal::setContainer($this->container);
  $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->time = $this
    ->getMockBuilder('\\Drupal\\Component\\Datetime\\TimeInterface')
    ->disableOriginalConstructor()
    ->getMock();
  $this->time
    ->expects($this
    ->any())
    ->method('getRequestTime')
    ->willReturn(1000101);
  $this->forcePasswordChangeService = new ForcePasswordChangeService($this->mapper, $this->currentUser, $this->configFactory, $this->userData, $this->time);
}