UpdateLastPasswordConfirmCommandTest.php 1010 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. declare(strict_types=1);
  7. namespace Test\Authentication\Login;
  8. use OC\Authentication\Login\UpdateLastPasswordConfirmCommand;
  9. use OCP\ISession;
  10. use PHPUnit\Framework\MockObject\MockObject;
  11. class UpdateLastPasswordConfirmCommandTest extends ALoginCommandTest {
  12. /** @var ISession|MockObject */
  13. private $session;
  14. protected function setUp(): void {
  15. parent::setUp();
  16. $this->session = $this->createMock(ISession::class);
  17. $this->cmd = new UpdateLastPasswordConfirmCommand(
  18. $this->session
  19. );
  20. }
  21. public function testProcess() {
  22. $data = $this->getLoggedInLoginData();
  23. $this->user->expects($this->once())
  24. ->method('getLastLogin')
  25. ->willReturn(1234);
  26. $this->session->expects($this->once())
  27. ->method('set')
  28. ->with(
  29. 'last-password-confirm',
  30. 1234
  31. );
  32. $result = $this->cmd->process($data);
  33. $this->assertTrue($result->isSuccess());
  34. }
  35. }