0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-01-16 08:09:00 +00:00
nextcloud_server/apps/settings/tests/Settings/Personal/Security/PasswordTest.php
Christoph Wurst 49dd79eabb
refactor: Add void return type to PHPUnit test methods
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2024-09-15 22:32:31 +02:00

58 lines
1.3 KiB
PHP

<?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 {
/** @var IUserManager|MockObject */
private $userManager;
/** @var string */
private $uid;
/** @var Password */
private $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);
}
}