blob: 7b011d706738020214a479c8fe11d95fe98a7af2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<?php
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
namespace Test\Authentication\Login;
use OC\Authentication\Login\LoggedInCheckCommand;
use OC\Core\Controller\LoginController;
use OCP\EventDispatcher\IEventDispatcher;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
class LoggedInCheckCommandTest extends ALoginTestCommand {
/** @var LoggerInterface|MockObject */
private $logger;
/** @var IEventDispatcher|MockObject */
private $dispatcher;
protected function setUp(): void {
parent::setUp();
$this->logger = $this->createMock(LoggerInterface::class);
$this->dispatcher = $this->createMock(IEventDispatcher::class);
$this->cmd = new LoggedInCheckCommand(
$this->logger,
$this->dispatcher
);
}
public function testProcessSuccessfulLogin(): void {
$data = $this->getLoggedInLoginData();
$result = $this->cmd->process($data);
$this->assertTrue($result->isSuccess());
}
public function testProcessFailedLogin(): void {
$data = $this->getFailedLoginData();
$this->logger->expects($this->once())
->method('warning');
$result = $this->cmd->process($data);
$this->assertFalse($result->isSuccess());
$this->assertSame(LoginController::LOGIN_MSG_INVALIDPASSWORD, $result->getErrorMessage());
}
}
|