2016-08-15 10:24:56 -04:00
|
|
|
<?php
|
|
|
|
|
/**
|
2024-05-28 10:42:42 -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\Federation\Tests\Settings;
|
|
|
|
|
|
|
|
|
|
use OCA\Federation\Settings\Admin;
|
|
|
|
|
use OCA\Federation\TrustedServers;
|
|
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
2021-10-14 09:07:14 -04:00
|
|
|
use OCP\IL10N;
|
2016-08-15 10:24:56 -04:00
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
|
|
class AdminTest extends TestCase {
|
|
|
|
|
/** @var Admin */
|
|
|
|
|
private $admin;
|
|
|
|
|
/** @var TrustedServers */
|
|
|
|
|
private $trustedServers;
|
|
|
|
|
|
2019-11-27 09:27:18 -05:00
|
|
|
protected function setUp(): void {
|
2016-08-15 10:24:56 -04:00
|
|
|
parent::setUp();
|
2016-08-15 10:43:22 -04:00
|
|
|
$this->trustedServers = $this->getMockBuilder('\OCA\Federation\TrustedServers')->disableOriginalConstructor()->getMock();
|
2016-08-15 10:24:56 -04:00
|
|
|
$this->admin = new Admin(
|
2021-10-14 09:07:14 -04:00
|
|
|
$this->trustedServers,
|
|
|
|
|
$this->createMock(IL10N::class)
|
2016-08-15 10:24:56 -04:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetForm() {
|
|
|
|
|
$this->trustedServers
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('getServers')
|
|
|
|
|
->willReturn(['myserver', 'secondserver']);
|
|
|
|
|
|
|
|
|
|
$params = [
|
|
|
|
|
'trustedServers' => ['myserver', 'secondserver'],
|
|
|
|
|
];
|
|
|
|
|
$expected = new TemplateResponse('federation', 'settings-admin', $params, '');
|
|
|
|
|
$this->assertEquals($expected, $this->admin->getForm());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetSection() {
|
|
|
|
|
$this->assertSame('sharing', $this->admin->getSection());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGetPriority() {
|
|
|
|
|
$this->assertSame(30, $this->admin->getPriority());
|
|
|
|
|
}
|
|
|
|
|
}
|