aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Authentication/Login/CompleteLoginCommandTest.php
blob: 5b08368671f726fe2e72a89b38cf738852b5a269 (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
<?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\CompleteLoginCommand;
use OC\User\Session;
use PHPUnit\Framework\MockObject\MockObject;

class CompleteLoginCommandTest extends ALoginTestCommand {
	/** @var Session|MockObject */
	private $session;

	protected function setUp(): void {
		parent::setUp();

		$this->session = $this->createMock(Session::class);

		$this->cmd = new CompleteLoginCommand(
			$this->session
		);
	}

	public function testProcess(): void {
		$data = $this->getLoggedInLoginData();
		$this->session->expects($this->once())
			->method('completeLogin')
			->with(
				$this->user,
				$this->equalTo(
					[
						'loginName' => $this->username,
						'password' => $this->password,
					]
				)
			);

		$result = $this->cmd->process($data);

		$this->assertTrue($result->isSuccess());
	}
}