You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AdminTest.php 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OCA\FederatedFileSharing\Tests\Settings;
  27. use OCA\FederatedFileSharing\FederatedShareProvider;
  28. use OCA\FederatedFileSharing\Settings\Admin;
  29. use OCP\AppFramework\Http\TemplateResponse;
  30. use OCP\GlobalScale\IConfig;
  31. use Test\TestCase;
  32. class AdminTest extends TestCase {
  33. /** @var Admin */
  34. private $admin;
  35. /** @var \OCA\FederatedFileSharing\FederatedShareProvider */
  36. private $federatedShareProvider;
  37. /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
  38. private $gsConfig;
  39. protected function setUp(): void {
  40. parent::setUp();
  41. $this->federatedShareProvider = $this->createMock(FederatedShareProvider::class);
  42. $this->gsConfig = $this->createMock(IConfig::class);
  43. $this->admin = new Admin(
  44. $this->federatedShareProvider,
  45. $this->gsConfig
  46. );
  47. }
  48. public function sharingStateProvider() {
  49. return [
  50. [
  51. true,
  52. ],
  53. [
  54. false,
  55. ]
  56. ];
  57. }
  58. /**
  59. * @dataProvider sharingStateProvider
  60. * @param bool $state
  61. */
  62. public function testGetForm($state) {
  63. $this->federatedShareProvider
  64. ->expects($this->once())
  65. ->method('isOutgoingServer2serverShareEnabled')
  66. ->willReturn($state);
  67. $this->federatedShareProvider
  68. ->expects($this->once())
  69. ->method('isIncomingServer2serverShareEnabled')
  70. ->willReturn($state);
  71. $this->federatedShareProvider
  72. ->expects($this->once())
  73. ->method('isIncomingServer2serverShareEnabled')
  74. ->willReturn($state);
  75. $this->federatedShareProvider
  76. ->expects($this->once())
  77. ->method('isLookupServerQueriesEnabled')
  78. ->willReturn($state);
  79. $this->federatedShareProvider
  80. ->expects($this->once())
  81. ->method('isLookupServerUploadEnabled')
  82. ->willReturn($state);
  83. $this->federatedShareProvider
  84. ->expects($this->once())
  85. ->method('isFederatedGroupSharingSupported')
  86. ->willReturn($state);
  87. $this->federatedShareProvider
  88. ->expects($this->once())
  89. ->method('isOutgoingServer2serverGroupShareEnabled')
  90. ->willReturn($state);
  91. $this->federatedShareProvider
  92. ->expects($this->once())
  93. ->method('isIncomingServer2serverGroupShareEnabled')
  94. ->willReturn($state);
  95. $this->gsConfig->expects($this->once())->method('onlyInternalFederation')
  96. ->willReturn($state);
  97. $params = [
  98. 'internalOnly' => $state,
  99. 'outgoingServer2serverShareEnabled' => $state,
  100. 'incomingServer2serverShareEnabled' => $state,
  101. 'lookupServerEnabled' => $state,
  102. 'lookupServerUploadEnabled' => $state,
  103. 'federatedGroupSharingSupported' => $state,
  104. 'outgoingServer2serverGroupShareEnabled' => $state,
  105. 'incomingServer2serverGroupShareEnabled' => $state,
  106. ];
  107. $expected = new TemplateResponse('federatedfilesharing', 'settings-admin', $params, '');
  108. $this->assertEquals($expected, $this->admin->getForm());
  109. }
  110. public function testGetSection() {
  111. $this->assertSame('sharing', $this->admin->getSection());
  112. }
  113. public function testGetPriority() {
  114. $this->assertSame(20, $this->admin->getPriority());
  115. }
  116. }