AdminTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\Federation\Tests\Settings;
  7. use OCA\Federation\Settings\Admin;
  8. use OCA\Federation\TrustedServers;
  9. use OCP\AppFramework\Http\TemplateResponse;
  10. use OCP\IL10N;
  11. use Test\TestCase;
  12. class AdminTest extends TestCase {
  13. /** @var Admin */
  14. private $admin;
  15. /** @var TrustedServers */
  16. private $trustedServers;
  17. protected function setUp(): void {
  18. parent::setUp();
  19. $this->trustedServers = $this->getMockBuilder('\OCA\Federation\TrustedServers')->disableOriginalConstructor()->getMock();
  20. $this->admin = new Admin(
  21. $this->trustedServers,
  22. $this->createMock(IL10N::class)
  23. );
  24. }
  25. public function testGetForm() {
  26. $this->trustedServers
  27. ->expects($this->once())
  28. ->method('getServers')
  29. ->willReturn(['myserver', 'secondserver']);
  30. $params = [
  31. 'trustedServers' => ['myserver', 'secondserver'],
  32. ];
  33. $expected = new TemplateResponse('federation', 'settings-admin', $params, '');
  34. $this->assertEquals($expected, $this->admin->getForm());
  35. }
  36. public function testGetSection() {
  37. $this->assertSame('sharing', $this->admin->getSection());
  38. }
  39. public function testGetPriority() {
  40. $this->assertSame(30, $this->admin->getPriority());
  41. }
  42. }