aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/tests/Settings/AdminTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/tests/Settings/AdminTest.php')
-rw-r--r--apps/user_ldap/tests/Settings/AdminTest.php60
1 files changed, 21 insertions, 39 deletions
diff --git a/apps/user_ldap/tests/Settings/AdminTest.php b/apps/user_ldap/tests/Settings/AdminTest.php
index 44f253ad598..b17e96c1a68 100644
--- a/apps/user_ldap/tests/Settings/AdminTest.php
+++ b/apps/user_ldap/tests/Settings/AdminTest.php
@@ -1,28 +1,9 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\User_LDAP\Tests\Settings;
@@ -30,7 +11,9 @@ use OCA\User_LDAP\Configuration;
use OCA\User_LDAP\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
-use OCP\Template;
+use OCP\Server;
+use OCP\Template\ITemplateManager;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
/**
@@ -38,32 +21,31 @@ use Test\TestCase;
* @package OCA\User_LDAP\Tests\Settings
*/
class AdminTest extends TestCase {
- /** @var Admin */
- private $admin;
- /** @var IL10N */
- private $l10n;
+ private IL10N&MockObject $l10n;
+ private ITemplateManager $templateManager;
+ private Admin $admin;
protected function setUp(): void {
parent::setUp();
- $this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
+ $this->l10n = $this->createMock(IL10N::class);
+ $this->templateManager = Server::get(ITemplateManager::class);
$this->admin = new Admin(
- $this->l10n
+ $this->l10n,
+ $this->templateManager,
);
}
- /**
- * @UseDB
- */
- public function testGetForm() {
+ public function testGetForm(): void {
$prefixes = ['s01'];
$hosts = ['s01' => ''];
- $wControls = new Template('user_ldap', 'part.wizardcontrols');
+ $wControls = $this->templateManager->getTemplate('user_ldap', 'part.wizardcontrols');
$wControls = $wControls->fetchPage();
- $sControls = new Template('user_ldap', 'part.settingcontrols');
+ $sControls = $this->templateManager->getTemplate('user_ldap', 'part.settingcontrols');
$sControls = $sControls->fetchPage();
+ $parameters = [];
$parameters['serverConfigurationPrefixes'] = $prefixes;
$parameters['serverConfigurationHosts'] = $hosts;
$parameters['settingControls'] = $sControls;
@@ -73,18 +55,18 @@ class AdminTest extends TestCase {
$config = new Configuration('', false);
$defaults = $config->getDefaults();
foreach ($defaults as $key => $default) {
- $parameters[$key.'_default'] = $default;
+ $parameters[$key . '_default'] = $default;
}
$expected = new TemplateResponse('user_ldap', 'settings', $parameters);
$this->assertEquals($expected, $this->admin->getForm());
}
- public function testGetSection() {
+ public function testGetSection(): void {
$this->assertSame('ldap', $this->admin->getSection());
}
- public function testGetPriority() {
+ public function testGetPriority(): void {
$this->assertSame(5, $this->admin->getPriority());
}
}