nextcloud/apps/user_ldap/tests/Settings/AdminTest.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

65 lines
1.7 KiB
PHP
Raw Normal View History

2016-08-15 10:24:56 -04:00
<?php
declare(strict_types=1);
2016-08-15 10:24:56 -04:00
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
2016-08-15 10:24:56 -04:00
*/
namespace OCA\User_LDAP\Tests\Settings;
use OCA\User_LDAP\Configuration;
use OCA\User_LDAP\Settings\Admin;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
2016-08-15 10:24:56 -04:00
use OCP\IL10N;
use OCP\Server;
use OCP\Template\ITemplateManager;
use PHPUnit\Framework\MockObject\MockObject;
2016-08-15 10:24:56 -04:00
use Test\TestCase;
/**
* @package OCA\User_LDAP\Tests\Settings
*/
#[\PHPUnit\Framework\Attributes\Group(name: 'DB')]
2016-08-15 10:24:56 -04:00
class AdminTest extends TestCase {
private IL10N&MockObject $l10n;
private ITemplateManager $templateManager;
private IInitialState&MockObject $initialState;
private Admin $admin;
2016-08-15 10:24:56 -04:00
protected function setUp(): void {
2016-08-15 10:24:56 -04:00
parent::setUp();
$this->l10n = $this->createMock(IL10N::class);
$this->templateManager = Server::get(ITemplateManager::class);
$this->initialState = $this->createMock(IInitialState::class);
2016-08-15 10:24:56 -04:00
$this->admin = new Admin(
$this->l10n,
$this->templateManager,
$this->initialState,
2016-08-15 10:24:56 -04:00
);
}
public function testGetForm(): void {
$parameters = [];
2016-08-15 10:24:56 -04:00
// assign default values
$config = new Configuration('', false);
$defaults = $config->getDefaults();
foreach ($defaults as $key => $default) {
$parameters[$key . '_default'] = $default;
}
$expected = new TemplateResponse('user_ldap', 'settings', $parameters);
$this->assertEquals($expected, $this->admin->getForm());
}
public function testGetSection(): void {
$this->assertSame('ldap', $this->admin->getSection());
}
public function testGetPriority(): void {
$this->assertSame(5, $this->admin->getPriority());
}
}