blob: 34a4b8e296fd4d95013990870c7b517dd75b9910 (
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
|
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Settings\Tests\Settings\Personal\Security;
use OCA\Settings\Settings\Personal\Security\Password;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IUser;
use OCP\IUserManager;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class PasswordTest extends TestCase {
private IUserManager&MockObject $userManager;
private string $uid;
private Password $section;
protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
$this->uid = 'test123';
$this->section = new Password(
$this->userManager,
$this->uid
);
}
public function testGetForm(): void {
$user = $this->createMock(IUser::class);
$this->userManager->expects($this->once())
->method('get')
->with($this->uid)
->willReturn($user);
$user->expects($this->once())
->method('canChangePassword')
->willReturn(true);
$form = $this->section->getForm();
$expected = new TemplateResponse('settings', 'settings/personal/security/password', [
'passwordChangeSupported' => true,
]);
$this->assertEquals($expected, $form);
}
}
|