ClearLostPasswordTokensCommandTest.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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\ClearLostPasswordTokensCommand;
  9. use OCP\IConfig;
  10. use PHPUnit\Framework\MockObject\MockObject;
  11. class ClearLostPasswordTokensCommandTest extends ALoginCommandTest {
  12. /** @var IConfig|MockObject */
  13. private $config;
  14. protected function setUp(): void {
  15. parent::setUp();
  16. $this->config = $this->createMock(IConfig::class);
  17. $this->cmd = new ClearLostPasswordTokensCommand(
  18. $this->config
  19. );
  20. }
  21. public function testProcess(): void {
  22. $data = $this->getLoggedInLoginData();
  23. $this->user->expects($this->once())
  24. ->method('getUID')
  25. ->willReturn($this->username);
  26. $this->config->expects($this->once())
  27. ->method('deleteUserValue')
  28. ->with(
  29. $this->username,
  30. 'core',
  31. 'lostpassword'
  32. );
  33. $result = $this->cmd->process($data);
  34. $this->assertTrue($result->isSuccess());
  35. }
  36. }