PreLoginHookCommandTest.php 980 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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\PreLoginHookCommand;
  9. use OC\User\Manager;
  10. use OCP\IUserManager;
  11. use PHPUnit\Framework\MockObject\MockObject;
  12. class PreLoginHookCommandTest extends ALoginCommandTest {
  13. /** @var IUserManager|MockObject */
  14. private $userManager;
  15. protected function setUp(): void {
  16. parent::setUp();
  17. $this->userManager = $this->createMock(Manager::class);
  18. $this->cmd = new PreLoginHookCommand(
  19. $this->userManager
  20. );
  21. }
  22. public function testProcess(): void {
  23. $data = $this->getBasicLoginData();
  24. $this->userManager->expects($this->once())
  25. ->method('emit')
  26. ->with(
  27. '\OC\User',
  28. 'preLogin',
  29. [
  30. $this->username,
  31. $this->password,
  32. ]
  33. );
  34. $result = $this->cmd->process($data);
  35. $this->assertTrue($result->isSuccess());
  36. }
  37. }