No known key found for this signature in database
GPG Key ID: B9F6980CF6E759B1
35 changed files with 2107 additions and 67 deletions
-
100apps/encryption/tests/Settings/AdminTest.php
-
84apps/federatedfilesharing/tests/Settings/AdminTest.php
-
70apps/federation/tests/Settings/AdminTest.php
-
83apps/files/tests/Settings/AdminTest.php
-
109apps/files_external/tests/Settings/AdminTest.php
-
62apps/files_external/tests/Settings/SectionTest.php
-
52apps/systemtags/tests/Settings/AdminTest.php
-
9apps/theming/lib/Settings/Admin.php
-
1apps/theming/tests/Controller/ThemingControllerTest.php
-
155apps/theming/tests/Settings/AdminTest.php
-
62apps/theming/tests/Settings/SectionTest.php
-
25apps/updatenotification/tests/Controller/AdminControllerTest.php
-
10apps/user_ldap/lib/Settings/Admin.php
-
90apps/user_ldap/tests/Settings/AdminTest.php
-
62apps/user_ldap/tests/Settings/SectionTest.php
-
4lib/private/Settings/Admin/Additional.php
-
4lib/private/Settings/Admin/Encryption.php
-
3lib/private/Settings/Admin/Logging.php
-
15lib/private/Settings/Admin/Server.php
-
8lib/private/Settings/Admin/Sharing.php
-
3lib/private/Settings/Admin/TipsTricks.php
-
36lib/private/Settings/Manager.php
-
10lib/private/Settings/Section.php
-
32settings/Controller/AdminSettingsController.php
-
2tests/Core/Templates/TemplatesTest.php
-
72tests/Settings/Controller/AdminSettingsControllerTest.php
-
10tests/Settings/Controller/CheckSetupControllerTest.php
-
127tests/lib/Settings/Admin/AdditionalTest.php
-
128tests/lib/Settings/Admin/EncryptionTest.php
-
91tests/lib/Settings/Admin/LoggingTest.php
-
154tests/lib/Settings/Admin/ServerTest.php
-
151tests/lib/Settings/Admin/SharingTest.php
-
91tests/lib/Settings/Admin/TipsTricksTest.php
-
220tests/lib/Settings/ManagerTest.php
-
39tests/lib/Settings/SectionTest.php
@ -0,0 +1,100 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Encryption\Tests\Settings; |
|||
|
|||
use OCA\Encryption\Settings\Admin; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\IConfig; |
|||
use OCP\ISession; |
|||
use OCP\IUserManager; |
|||
use OCP\IUserSession; |
|||
use OCP\IL10N; |
|||
use OCP\ILogger; |
|||
use Test\TestCase; |
|||
|
|||
class AdminTest extends TestCase { |
|||
/** @var Admin */ |
|||
private $admin; |
|||
/** @var IL10N */ |
|||
private $l; |
|||
/** @var ILogger */ |
|||
private $logger; |
|||
/** @var IUserSession */ |
|||
private $userSession; |
|||
/** @var IConfig */ |
|||
private $config; |
|||
/** @var IUserManager */ |
|||
private $userManager; |
|||
/** @var ISession */ |
|||
private $session; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
|
|||
$this->l = $this->createMock('\OCP\IL10N'); |
|||
$this->logger = $this->createMock('\OCP\ILogger'); |
|||
$this->userSession = $this->createMock('\OCP\IUserSession'); |
|||
$this->config = $this->createMock('\OCP\IConfig'); |
|||
$this->userManager = $this->createMock('\OCP\IUserManager'); |
|||
$this->session = $this->createMock('\OCP\ISession'); |
|||
|
|||
$this->admin = new Admin( |
|||
$this->l, |
|||
$this->logger, |
|||
$this->userSession, |
|||
$this->config, |
|||
$this->userManager, |
|||
$this->session |
|||
); |
|||
} |
|||
|
|||
public function testGetForm() { |
|||
$this->config |
|||
->expects($this->at(0)) |
|||
->method('getAppValue') |
|||
->with('encryption', 'recoveryAdminEnabled', '0') |
|||
->willReturn(1); |
|||
$this->config |
|||
->expects($this->at(1)) |
|||
->method('getAppValue') |
|||
->with('encryption', 'encryptHomeStorage', '1') |
|||
->willReturn(1); |
|||
$params = [ |
|||
'recoveryEnabled' => 1, |
|||
'initStatus' => '0', |
|||
'encryptHomeStorage' => false, |
|||
'masterKeyEnabled' => false |
|||
]; |
|||
$expected = new TemplateResponse('encryption', 'settings-admin', $params, ''); |
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetSection() { |
|||
$this->assertSame('encryption', $this->admin->getSection()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(5, $this->admin->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,84 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\FederatedFileSharing\Tests\Settings; |
|||
|
|||
use OCA\FederatedFileSharing\Settings\Admin; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use Test\TestCase; |
|||
|
|||
class AdminTest extends TestCase { |
|||
/** @var Admin */ |
|||
private $admin; |
|||
/** @var \OCA\FederatedFileSharing\FederatedShareProvider */ |
|||
private $federatedShareProvider; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->federatedShareProvider = $this->createMock('\OCA\FederatedFileSharing\FederatedShareProvider'); |
|||
$this->admin = new Admin( |
|||
$this->federatedShareProvider |
|||
); |
|||
} |
|||
|
|||
public function sharingStateProvider() { |
|||
return [ |
|||
[ |
|||
true, |
|||
], |
|||
[ |
|||
false, |
|||
] |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* @dataProvider sharingStateProvider |
|||
* @param bool $state |
|||
*/ |
|||
public function testGetForm($state) { |
|||
$this->federatedShareProvider |
|||
->expects($this->once()) |
|||
->method('isOutgoingServer2serverShareEnabled') |
|||
->willReturn($state); |
|||
$this->federatedShareProvider |
|||
->expects($this->once()) |
|||
->method('isIncomingServer2serverShareEnabled') |
|||
->willReturn($state); |
|||
|
|||
$params = [ |
|||
'outgoingServer2serverShareEnabled' => $state, |
|||
'incomingServer2serverShareEnabled' => $state, |
|||
]; |
|||
$expected = new TemplateResponse('federatedfilesharing', 'settings-admin', $params, ''); |
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetSection() { |
|||
$this->assertSame('sharing', $this->admin->getSection()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(20, $this->admin->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Federation\Tests\Settings; |
|||
|
|||
use OCA\Federation\Settings\Admin; |
|||
use OCA\Federation\TrustedServers; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use Test\TestCase; |
|||
|
|||
class AdminTest extends TestCase { |
|||
/** @var Admin */ |
|||
private $admin; |
|||
/** @var TrustedServers */ |
|||
private $trustedServers; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->trustedServers = $this->createMock('\OCA\Federation\TrustedServers'); |
|||
$this->admin = new Admin( |
|||
$this->trustedServers |
|||
); |
|||
} |
|||
|
|||
public function testGetForm() { |
|||
$this->trustedServers |
|||
->expects($this->once()) |
|||
->method('getServers') |
|||
->willReturn(['myserver', 'secondserver']); |
|||
$this->trustedServers |
|||
->expects($this->once()) |
|||
->method('getAutoAddServers') |
|||
->willReturn(['autoserver1', 'autoserver2']); |
|||
|
|||
$params = [ |
|||
'trustedServers' => ['myserver', 'secondserver'], |
|||
'autoAddServers' => ['autoserver1', 'autoserver2'], |
|||
]; |
|||
$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()); |
|||
} |
|||
} |
|||
@ -0,0 +1,83 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Files\Tests\Settings; |
|||
|
|||
use bantu\IniGetWrapper\IniGetWrapper; |
|||
use OCA\Files\Settings\Admin; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\IRequest; |
|||
use OCP\Util; |
|||
use Test\TestCase; |
|||
|
|||
class AdminTest extends TestCase { |
|||
/** @var Admin */ |
|||
private $admin; |
|||
/** @var IniGetWrapper */ |
|||
private $iniGetWrapper; |
|||
/** @var IRequest */ |
|||
private $request; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->iniGetWrapper = $this->createMock('\bantu\IniGetWrapper\IniGetWrapper'); |
|||
$this->request = $this->createMock('\OCP\IRequest'); |
|||
$this->admin = new Admin( |
|||
$this->iniGetWrapper, |
|||
$this->request |
|||
); |
|||
} |
|||
|
|||
public function testGetForm() { |
|||
$htaccessWorking = (getenv('htaccessWorking') == 'true'); |
|||
$htaccessWritable = is_writable(\OC::$SERVERROOT.'/.htaccess'); |
|||
$userIniWritable = is_writable(\OC::$SERVERROOT.'/.user.ini'); |
|||
|
|||
$this->iniGetWrapper |
|||
->expects($this->at(0)) |
|||
->method('getBytes') |
|||
->with('upload_max_filesize') |
|||
->willReturn(1234); |
|||
$this->iniGetWrapper |
|||
->expects($this->at(1)) |
|||
->method('getBytes') |
|||
->with('post_max_size') |
|||
->willReturn(1234); |
|||
$params = [ |
|||
'uploadChangable' => (($htaccessWorking and $htaccessWritable) or $userIniWritable ), |
|||
'uploadMaxFilesize' => '1 KB', |
|||
'displayMaxPossibleUploadSize' => PHP_INT_SIZE === 4, |
|||
'maxPossibleUploadSize' => Util::humanFileSize(PHP_INT_MAX), |
|||
]; |
|||
$expected = new TemplateResponse('files', 'admin', $params, ''); |
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetSection() { |
|||
$this->assertSame('additional', $this->admin->getSection()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(5, $this->admin->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,109 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Files_External\Tests\Settings; |
|||
|
|||
use OCA\Files_External\Lib\Auth\Password\GlobalAuth; |
|||
use OCA\Files_External\Service\BackendService; |
|||
use OCA\Files_External\Service\GlobalStoragesService; |
|||
use OCA\Files_External\Settings\Admin; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\Encryption\IManager; |
|||
use Test\TestCase; |
|||
|
|||
class AdminTest extends TestCase { |
|||
/** @var Admin */ |
|||
private $admin; |
|||
/** @var IManager */ |
|||
private $encryptionManager; |
|||
/** @var GlobalStoragesService */ |
|||
private $globalStoragesService; |
|||
/** @var BackendService */ |
|||
private $backendService; |
|||
/** @var GlobalAuth */ |
|||
private $globalAuth; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->encryptionManager = $this->createMock('\OCP\Encryption\IManager'); |
|||
$this->globalStoragesService = $this->createMock('\OCA\Files_External\Service\GlobalStoragesService'); |
|||
$this->backendService = $this->createMock('\OCA\Files_External\Service\BackendService'); |
|||
$this->globalAuth = $this->createMock('\OCA\Files_External\Lib\Auth\Password\GlobalAuth'); |
|||
|
|||
$this->admin = new Admin( |
|||
$this->encryptionManager, |
|||
$this->globalStoragesService, |
|||
$this->backendService, |
|||
$this->globalAuth |
|||
); |
|||
} |
|||
|
|||
public function testGetForm() { |
|||
$this->encryptionManager |
|||
->expects($this->once()) |
|||
->method('isEnabled') |
|||
->willReturn(false); |
|||
$this->globalStoragesService |
|||
->expects($this->once()) |
|||
->method('getStorages') |
|||
->willReturn(['a', 'b', 'c']); |
|||
$this->backendService |
|||
->expects($this->once()) |
|||
->method('getAvailableBackends') |
|||
->willReturn(['d', 'e', 'f']); |
|||
$this->backendService |
|||
->expects($this->once()) |
|||
->method('getAuthMechanisms') |
|||
->willReturn(['g', 'h', 'i']); |
|||
$this->backendService |
|||
->expects($this->once()) |
|||
->method('isUserMountingAllowed') |
|||
->willReturn(true); |
|||
$this->globalAuth |
|||
->expects($this->once()) |
|||
->method('getAuth') |
|||
->with('') |
|||
->willReturn('asdf:asdf'); |
|||
$params = [ |
|||
'encryptionEnabled' => false, |
|||
'visibilityType' => BackendService::VISIBILITY_ADMIN, |
|||
'storages' => ['a', 'b', 'c'], |
|||
'backends' => ['d', 'e', 'f'], |
|||
'authMechanisms' => ['g', 'h', 'i'], |
|||
'dependencies' => \OC_Mount_Config::dependencyMessage($this->backendService->getBackends()), |
|||
'allowUserMounting' => true, |
|||
'globalCredentials' => 'asdf:asdf', |
|||
'globalCredentialsUid' => '', |
|||
]; |
|||
$expected = new TemplateResponse('files_external', 'settings', $params, ''); |
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetSection() { |
|||
$this->assertSame('externalstorages', $this->admin->getSection()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(40, $this->admin->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Files_External\Tests\Settings; |
|||
|
|||
use OCA\Files_External\Settings\Section; |
|||
use OCP\IL10N; |
|||
use Test\TestCase; |
|||
|
|||
class SectionTest extends TestCase { |
|||
/** @var IL10N */ |
|||
private $l; |
|||
/** @var Section */ |
|||
private $section; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->l = $this->createMock('\OCP\IL10N'); |
|||
|
|||
$this->section = new Section( |
|||
$this->l |
|||
); |
|||
} |
|||
|
|||
public function testGetID() { |
|||
$this->assertSame('externalstorages', $this->section->getID()); |
|||
} |
|||
|
|||
public function testGetName() { |
|||
$this->l |
|||
->expects($this->once()) |
|||
->method('t') |
|||
->with('External storages') |
|||
->willReturn('External storages'); |
|||
|
|||
$this->assertSame('External storages', $this->section->getName()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(10, $this->section->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\SystemTags\Tests\Settings; |
|||
|
|||
use OCA\SystemTags\Settings\Admin; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use Test\TestCase; |
|||
|
|||
class AdminTest extends TestCase { |
|||
/** @var Admin */ |
|||
private $admin; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
|
|||
$this->admin = new Admin(); |
|||
} |
|||
|
|||
public function testGetForm() { |
|||
$expected = new TemplateResponse('systemtags', 'admin', [], ''); |
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetSection() { |
|||
$this->assertSame('sharing', $this->admin->getSection()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(70, $this->admin->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,155 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Theming\Tests\Settings; |
|||
|
|||
use OCA\Theming\Settings\Admin; |
|||
use OCA\Theming\ThemingDefaults; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\IConfig; |
|||
use OCP\IL10N; |
|||
use OCP\IURLGenerator; |
|||
use Test\TestCase; |
|||
|
|||
class AdminTest extends TestCase { |
|||
/** @var Admin */ |
|||
private $admin; |
|||
/** @var IConfig */ |
|||
private $config; |
|||
/** @var ThemingDefaults */ |
|||
private $themingDefaults; |
|||
/** @var IURLGenerator */ |
|||
private $urlGenerator; |
|||
/** @var IL10N */ |
|||
private $l10n; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->config = $this->createMock('\OCP\IConfig'); |
|||
$this->l10n = $this->createMock('\OCP\IL10N'); |
|||
$this->themingDefaults = $this->createMock('\OCA\Theming\ThemingDefaults'); |
|||
$this->urlGenerator = $this->createMock('\OCP\IURLGenerator'); |
|||
|
|||
$this->admin = new Admin( |
|||
$this->config, |
|||
$this->l10n, |
|||
$this->themingDefaults, |
|||
$this->urlGenerator |
|||
); |
|||
} |
|||
|
|||
public function testGetFormNoErrors() { |
|||
$this->config |
|||
->expects($this->once()) |
|||
->method('getSystemValue') |
|||
->with('theme', '') |
|||
->willReturn(''); |
|||
$this->themingDefaults |
|||
->expects($this->once()) |
|||
->method('getEntity') |
|||
->willReturn('MyEntity'); |
|||
$this->themingDefaults |
|||
->expects($this->once()) |
|||
->method('getBaseUrl') |
|||
->willReturn('https://example.com'); |
|||
$this->themingDefaults |
|||
->expects($this->once()) |
|||
->method('getSlogan') |
|||
->willReturn('MySlogan'); |
|||
$this->themingDefaults |
|||
->expects($this->once()) |
|||
->method('getMailHeaderColor') |
|||
->willReturn('#fff'); |
|||
$this->urlGenerator |
|||
->expects($this->once()) |
|||
->method('linkToRoute') |
|||
->with('theming.Theming.updateLogo') |
|||
->willReturn('/my/route'); |
|||
$params = [ |
|||
'themable' => true, |
|||
'errorMessage' => '', |
|||
'name' => 'MyEntity', |
|||
'url' => 'https://example.com', |
|||
'slogan' => 'MySlogan', |
|||
'color' => '#fff', |
|||
'uploadLogoRoute' => '/my/route', |
|||
]; |
|||
|
|||
$expected = new TemplateResponse('theming', 'settings-admin', $params, ''); |
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetFormWithErrors() { |
|||
$this->config |
|||
->expects($this->once()) |
|||
->method('getSystemValue') |
|||
->with('theme', '') |
|||
->willReturn('MyCustomTheme'); |
|||
$this->l10n |
|||
->expects($this->once()) |
|||
->method('t') |
|||
->with('You already use a custom theme') |
|||
->willReturn('You already use a custom theme'); |
|||
$this->themingDefaults |
|||
->expects($this->once()) |
|||
->method('getEntity') |
|||
->willReturn('MyEntity'); |
|||
$this->themingDefaults |
|||
->expects($this->once()) |
|||
->method('getBaseUrl') |
|||
->willReturn('https://example.com'); |
|||
$this->themingDefaults |
|||
->expects($this->once()) |
|||
->method('getSlogan') |
|||
->willReturn('MySlogan'); |
|||
$this->themingDefaults |
|||
->expects($this->once()) |
|||
->method('getMailHeaderColor') |
|||
->willReturn('#fff'); |
|||
$this->urlGenerator |
|||
->expects($this->once()) |
|||
->method('linkToRoute') |
|||
->with('theming.Theming.updateLogo') |
|||
->willReturn('/my/route'); |
|||
$params = [ |
|||
'themable' => false, |
|||
'errorMessage' => 'You already use a custom theme', |
|||
'name' => 'MyEntity', |
|||
'url' => 'https://example.com', |
|||
'slogan' => 'MySlogan', |
|||
'color' => '#fff', |
|||
'uploadLogoRoute' => '/my/route', |
|||
]; |
|||
|
|||
$expected = new TemplateResponse('theming', 'settings-admin', $params, ''); |
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetSection() { |
|||
$this->assertSame('theming', $this->admin->getSection()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(5, $this->admin->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Theming\Tests\Settings; |
|||
|
|||
use OCA\Theming\Settings\Section; |
|||
use OCP\IL10N; |
|||
use Test\TestCase; |
|||
|
|||
class SectionTest extends TestCase { |
|||
/** @var IL10N */ |
|||
private $l; |
|||
/** @var Section */ |
|||
private $section; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->l = $this->createMock('\OCP\IL10N'); |
|||
|
|||
$this->section = new Section( |
|||
$this->l |
|||
); |
|||
} |
|||
|
|||
public function testGetID() { |
|||
$this->assertSame('theming', $this->section->getID()); |
|||
} |
|||
|
|||
public function testGetName() { |
|||
$this->l |
|||
->expects($this->once()) |
|||
->method('t') |
|||
->with('Theming') |
|||
->willReturn('Theming'); |
|||
|
|||
$this->assertSame('Theming', $this->section->getName()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(30, $this->section->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,90 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\User_LDAP\Tests\Settings; |
|||
|
|||
use OCA\User_LDAP\Configuration; |
|||
use OCA\User_LDAP\Helper; |
|||
use OCA\User_LDAP\Settings\Admin; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\IL10N; |
|||
use OCP\Template; |
|||
use Test\TestCase; |
|||
|
|||
/** |
|||
* @group DB |
|||
* @package OCA\User_LDAP\Tests\Settings |
|||
*/ |
|||
class AdminTest extends TestCase { |
|||
/** @var Admin */ |
|||
private $admin; |
|||
/** @var IL10N */ |
|||
private $l10n; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->l10n = $this->createMock('\OCP\IL10N'); |
|||
|
|||
$this->admin = new Admin( |
|||
$this->l10n |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* @UseDB |
|||
*/ |
|||
public function testGetForm() { |
|||
|
|||
$helper = new Helper(); |
|||
$prefixes = $helper->getServerConfigurationPrefixes(); |
|||
$hosts = $helper->getServerConfigurationHosts(); |
|||
|
|||
$wControls = new Template('user_ldap', 'part.wizardcontrols'); |
|||
$wControls = $wControls->fetchPage(); |
|||
$sControls = new Template('user_ldap', 'part.settingcontrols'); |
|||
$sControls = $sControls->fetchPage(); |
|||
|
|||
$parameters['serverConfigurationPrefixes'] = $prefixes; |
|||
$parameters['serverConfigurationHosts'] = $hosts; |
|||
$parameters['settingControls'] = $sControls; |
|||
$parameters['wizardControls'] = $wControls; |
|||
|
|||
// 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() { |
|||
$this->assertSame('ldap', $this->admin->getSection()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(5, $this->admin->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\User_LDAP\Tests\Settings; |
|||
|
|||
use OCA\User_LDAP\Settings\Section; |
|||
use OCP\IL10N; |
|||
use Test\TestCase; |
|||
|
|||
class SectionTest extends TestCase { |
|||
/** @var IL10N */ |
|||
private $l; |
|||
/** @var Section */ |
|||
private $section; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->l = $this->createMock('\OCP\IL10N'); |
|||
|
|||
$this->section = new Section( |
|||
$this->l |
|||
); |
|||
} |
|||
|
|||
public function testGetID() { |
|||
$this->assertSame('ldap', $this->section->getID()); |
|||
} |
|||
|
|||
public function testGetName() { |
|||
$this->l |
|||
->expects($this->once()) |
|||
->method('t') |
|||
->with('LDAP / AD integration') |
|||
->willReturn('LDAP / AD integration'); |
|||
|
|||
$this->assertSame('LDAP / AD integration', $this->section->getName()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(25, $this->section->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
namespace Tests\Settings\Controller; |
|||
|
|||
|
|||
use OC\Settings\Admin\TipsTricks; |
|||
use OC\Settings\Controller\AdminSettingsController; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\INavigationManager; |
|||
use OCP\IRequest; |
|||
use OCP\Settings\IManager; |
|||
use Test\TestCase; |
|||
|
|||
class AdminSettingsControllerTest extends TestCase { |
|||
/** @var AdminSettingsController */ |
|||
private $adminSettingsController; |
|||
/** @var IRequest */ |
|||
private $request; |
|||
/** @var INavigationManager */ |
|||
private $navigationManager; |
|||
/** @var IManager */ |
|||
private $settingsManager; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
|
|||
$this->request = $this->createMock('\OCP\IRequest'); |
|||
$this->navigationManager = $this->createMock('\OCP\INavigationManager'); |
|||
$this->settingsManager = $this->createMock('\OCP\Settings\IManager'); |
|||
|
|||
$this->adminSettingsController = new AdminSettingsController( |
|||
'settings', |
|||
$this->request, |
|||
$this->navigationManager, |
|||
$this->settingsManager |
|||
); |
|||
} |
|||
|
|||
public function testIndex() { |
|||
$this->settingsManager |
|||
->expects($this->once()) |
|||
->method('getAdminSections') |
|||
->willReturn([]); |
|||
$this->settingsManager |
|||
->expects($this->once()) |
|||
->method('getAdminSettings') |
|||
->with('test') |
|||
->willReturn([5 => new TipsTricks($this->createMock('\OCP\IConfig'))]); |
|||
$expected = new TemplateResponse('settings', 'admin/frame', ['forms' => [], 'content' => '']); |
|||
$this->assertEquals($expected, $this->adminSettingsController->index('test')); |
|||
} |
|||
} |
|||
@ -0,0 +1,127 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace Test\Settings\Admin; |
|||
|
|||
use OC\Settings\Admin\Additional; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\IConfig; |
|||
use Test\TestCase; |
|||
|
|||
class AdditionalTest extends TestCase { |
|||
/** @var Additional */ |
|||
private $admin; |
|||
/** @var IConfig */ |
|||
private $config; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->config = $this->createMock('\OCP\IConfig'); |
|||
|
|||
$this->admin = new Additional( |
|||
$this->config |
|||
); |
|||
} |
|||
|
|||
public function testGetForm() { |
|||
$this->config |
|||
->expects($this->at(0)) |
|||
->method('getSystemValue') |
|||
->with('mail_domain', '') |
|||
->willReturn('mx.nextcloud.com'); |
|||
$this->config |
|||
->expects($this->at(1)) |
|||
->method('getSystemValue') |
|||
->with('mail_from_address', '') |
|||
->willReturn('no-reply@nextcloud.com'); |
|||
$this->config |
|||
->expects($this->at(2)) |
|||
->method('getSystemValue') |
|||
->with('mail_smtpmode', '') |
|||
->willReturn('php'); |
|||
$this->config |
|||
->expects($this->at(3)) |
|||
->method('getSystemValue') |
|||
->with('mail_smtpsecure', '') |
|||
->willReturn(true); |
|||
$this->config |
|||
->expects($this->at(4)) |
|||
->method('getSystemValue') |
|||
->with('mail_smtphost', '') |
|||
->willReturn('smtp.nextcloud.com'); |
|||
$this->config |
|||
->expects($this->at(5)) |
|||
->method('getSystemValue') |
|||
->with('mail_smtpport', '') |
|||
->willReturn(25); |
|||
$this->config |
|||
->expects($this->at(6)) |
|||
->method('getSystemValue') |
|||
->with('mail_smtpauthtype', '') |
|||
->willReturn('login'); |
|||
$this->config |
|||
->expects($this->at(7)) |
|||
->method('getSystemValue') |
|||
->with('mail_smtpauth', false) |
|||
->willReturn(true); |
|||
$this->config |
|||
->expects($this->at(8)) |
|||
->method('getSystemValue') |
|||
->with('mail_smtpname', '') |
|||
->willReturn('smtp.sender.com'); |
|||
$this->config |
|||
->expects($this->at(9)) |
|||
->method('getSystemValue') |
|||
->with('mail_smtppassword', '') |
|||
->willReturn('mypassword'); |
|||
|
|||
$expected = new TemplateResponse( |
|||
'settings', |
|||
'admin/additional-mail', |
|||
[ |
|||
'sendmail_is_available' => (bool) \OC_Helper::findBinaryPath('sendmail'), |
|||
'mail_domain' => 'mx.nextcloud.com', |
|||
'mail_from_address' => 'no-reply@nextcloud.com', |
|||
'mail_smtpmode' => 'php', |
|||
'mail_smtpsecure' => true, |
|||
'mail_smtphost' => 'smtp.nextcloud.com', |
|||
'mail_smtpport' => 25, |
|||
'mail_smtpauthtype' => 'login', |
|||
'mail_smtpauth' => true, |
|||
'mail_smtpname' => 'smtp.sender.com', |
|||
'mail_smtppassword' => 'mypassword', |
|||
], |
|||
'' |
|||
); |
|||
|
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetSection() { |
|||
$this->assertSame('additional', $this->admin->getSection()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(0, $this->admin->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,128 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace Test\Settings\Admin; |
|||
|
|||
use OC\Encryption\Manager; |
|||
use OC\Settings\Admin\Encryption; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\IUserManager; |
|||
use Test\TestCase; |
|||
|
|||
class EncryptionTest extends TestCase { |
|||
/** @var Encryption */ |
|||
private $admin; |
|||
/** @var Manager */ |
|||
private $manager; |
|||
/** @var IUserManager */ |
|||
private $userManager; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->manager = $this->createMock('\OC\Encryption\Manager'); |
|||
$this->userManager = $this->createMock('\OCP\IUserManager'); |
|||
|
|||
$this->admin = new Encryption( |
|||
$this->manager, |
|||
$this->userManager |
|||
); |
|||
} |
|||
|
|||
/** |
|||
* @return array |
|||
*/ |
|||
public function encryptionSettingsProvider() { |
|||
return [ |
|||
[true], |
|||
[false], |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* @dataProvider encryptionSettingsProvider |
|||
* @param bool $enabled |
|||
*/ |
|||
public function testGetFormWithOnlyOneBackend($enabled) { |
|||
$this->manager |
|||
->expects($this->once()) |
|||
->method('isEnabled') |
|||
->willReturn($enabled); |
|||
$this->manager |
|||
->expects($this->once()) |
|||
->method('isReady') |
|||
->willReturn($enabled); |
|||
$this->userManager |
|||
->expects($this->once()) |
|||
->method('getBackends') |
|||
->willReturn(['entry']); |
|||
$expected = new TemplateResponse( |
|||
'settings', |
|||
'admin/encryption', |
|||
[ |
|||
'encryptionEnabled' => $enabled, |
|||
'encryptionReady' => $enabled, |
|||
'externalBackendsEnabled' => false, |
|||
], |
|||
'' |
|||
); |
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
/** |
|||
* @dataProvider encryptionSettingsProvider |
|||
* @param bool $enabled |
|||
*/ |
|||
public function testGetFormWithMultipleBackends($enabled) { |
|||
$this->manager |
|||
->expects($this->once()) |
|||
->method('isEnabled') |
|||
->willReturn($enabled); |
|||
$this->manager |
|||
->expects($this->once()) |
|||
->method('isReady') |
|||
->willReturn($enabled); |
|||
$this->userManager |
|||
->expects($this->once()) |
|||
->method('getBackends') |
|||
->willReturn(['entry', 'entry']); |
|||
$expected = new TemplateResponse( |
|||
'settings', |
|||
'admin/encryption', |
|||
[ |
|||
'encryptionEnabled' => $enabled, |
|||
'encryptionReady' => $enabled, |
|||
'externalBackendsEnabled' => true, |
|||
], |
|||
'' |
|||
); |
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetSection() { |
|||
$this->assertSame('encryption', $this->admin->getSection()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(0, $this->admin->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,91 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace Test\Settings\Admin; |
|||
|
|||
use OC\Settings\Admin\Logging; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\IConfig; |
|||
use Test\TestCase; |
|||
use OC\Log\File as LogFile; |
|||
|
|||
class LoggingTest extends TestCase { |
|||
/** @var Logging */ |
|||
private $admin; |
|||
/** @var IConfig */ |
|||
private $config; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->config = $this->createMock('\OCP\IConfig'); |
|||
|
|||
$this->admin = new Logging( |
|||
$this->config |
|||
); |
|||
} |
|||
|
|||
public function testGetForm() { |
|||
$this->config |
|||
->expects($this->at(0)) |
|||
->method('getSystemValue') |
|||
->with('log_type', 'file') |
|||
->willReturn('owncloud'); |
|||
$this->config |
|||
->expects($this->at(1)) |
|||
->method('getSystemValue') |
|||
->with('loglevel', 2) |
|||
->willReturn(3); |
|||
|
|||
$numEntriesToLoad = 5; |
|||
$entries = LogFile::getEntries($numEntriesToLoad + 1); |
|||
$entriesRemaining = count($entries) > $numEntriesToLoad; |
|||
$entries = array_slice($entries, 0, $numEntriesToLoad); |
|||
|
|||
$logFileExists = file_exists(LogFile::getLogFilePath()) ; |
|||
$logFileSize = $logFileExists ? filesize(LogFile::getLogFilePath()) : 0; |
|||
|
|||
$expected = new TemplateResponse( |
|||
'settings', |
|||
'admin/logging', |
|||
[ |
|||
'loglevel' => 3, |
|||
'entries' => $entries, |
|||
'entriesremain' => $entriesRemaining, |
|||
'doesLogFileExist' => $logFileExists, |
|||
'logFileSize' => $logFileSize, |
|||
'showLog' => true, |
|||
], |
|||
'' |
|||
); |
|||
|
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetSection() { |
|||
$this->assertSame('logging', $this->admin->getSection()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(0, $this->admin->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,154 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace Test\Settings\Admin; |
|||
|
|||
use Doctrine\DBAL\Platforms\SqlitePlatform; |
|||
use OC\Settings\Admin\Server; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\IConfig; |
|||
use OCP\IDBConnection; |
|||
use OCP\IL10N; |
|||
use OCP\Lock\ILockingProvider; |
|||
use Test\TestCase; |
|||
|
|||
class ServerTest extends TestCase { |
|||
/** @var Server */ |
|||
private $admin; |
|||
/** @var IDBConnection */ |
|||
private $dbConnection; |
|||
/** @var IConfig */ |
|||
private $config; |
|||
/** @var ILockingProvider */ |
|||
private $lockingProvider; |
|||
/** @var IL10N */ |
|||
private $l10n; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->config = $this->createMock('\OCP\IConfig'); |
|||
$this->dbConnection = $this->createMock('\OCP\IDBConnection'); |
|||
$this->lockingProvider = $this->createMock('\OCP\Lock\ILockingProvider'); |
|||
$this->l10n = $this->createMock('\OCP\IL10N'); |
|||
|
|||
$this->admin = new Server( |
|||
$this->dbConnection, |
|||
$this->config, |
|||
$this->lockingProvider, |
|||
$this->l10n |
|||
); |
|||
} |
|||
|
|||
public function testGetForm() { |
|||
$this->dbConnection |
|||
->expects($this->once()) |
|||
->method('getDatabasePlatform') |
|||
->willReturn(new SqlitePlatform()); |
|||
$this->config |
|||
->expects($this->at(0)) |
|||
->method('getAppValue') |
|||
->with('core', 'backgroundjobs_mode', 'ajax') |
|||
->willReturn('ajax'); |
|||
$this->config |
|||
->expects($this->at(2)) |
|||
->method('getAppValue') |
|||
->with('core', 'backgroundjobs_mode', 'ajax') |
|||
->willReturn('ajax'); |
|||
$this->config |
|||
->expects($this->at(4)) |
|||
->method('getAppValue') |
|||
->with('core', 'lastcron', false) |
|||
->willReturn(false); |
|||
$this->config |
|||
->expects($this->at(5)) |
|||
->method('getAppValue') |
|||
->with('core', 'cronErrors') |
|||
->willReturn(''); |
|||
$this->config |
|||
->expects($this->at(1)) |
|||
->method('getSystemValue') |
|||
->with('check_for_working_wellknown_setup', true) |
|||
->willReturn(true); |
|||
$this->config |
|||
->expects($this->at(3)) |
|||
->method('getSystemValue') |
|||
->with('cron_log', true) |
|||
->willReturn(true); |
|||
$this->l10n |
|||
->expects($this->at(0)) |
|||
->method('t') |
|||
->with('APCu') |
|||
->willReturn('APCu'); |
|||
$this->l10n |
|||
->expects($this->at(1)) |
|||
->method('t') |
|||
->with('Redis') |
|||
->willReturn('Redis'); |
|||
$outdatedCaches = []; |
|||
$caches = [ |
|||
'apcu' => ['name' => 'APCu', 'version' => '4.0.6'], |
|||
'redis' => ['name' => 'Redis', 'version' => '2.2.5'], |
|||
]; |
|||
foreach ($caches as $php_module => $data) { |
|||
$isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<'); |
|||
if ($isOutdated) { |
|||
$outdatedCaches[$php_module] = $data; |
|||
} |
|||
} |
|||
$envPath = getenv('PATH'); |
|||
$expected = new TemplateResponse( |
|||
'settings', |
|||
'admin/server', |
|||
[ |
|||
// Diagnosis
|
|||
'readOnlyConfigEnabled' => \OC_Helper::isReadOnlyConfigEnabled(), |
|||
'isLocaleWorking' => \OC_Util::isSetLocaleWorking(), |
|||
'isAnnotationsWorking' => \OC_Util::isAnnotationsWorking(), |
|||
'checkForWorkingWellKnownSetup' => true, |
|||
'has_fileinfo' => \OC_Util::fileInfoLoaded(), |
|||
'invalidTransactionIsolationLevel' => false, |
|||
'getenvServerNotWorking' => empty($envPath), |
|||
'OutdatedCacheWarning' => $outdatedCaches, |
|||
'fileLockingType' => 'cache', |
|||
'suggestedOverwriteCliUrl' => '', |
|||
|
|||
// Background jobs
|
|||
'backgroundjobs_mode' => 'ajax', |
|||
'cron_log' => true, |
|||
'lastcron' => false, |
|||
'cronErrors' => '' |
|||
], |
|||
'' |
|||
); |
|||
|
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetSection() { |
|||
$this->assertSame('server', $this->admin->getSection()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(0, $this->admin->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,151 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace Test\Settings\Admin; |
|||
|
|||
use OC\Settings\Admin\Sharing; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\IConfig; |
|||
use Test\TestCase; |
|||
|
|||
class SharingTest extends TestCase { |
|||
/** @var Sharing */ |
|||
private $admin; |
|||
/** @var IConfig */ |
|||
private $config; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->config = $this->createMock('\OCP\IConfig'); |
|||
|
|||
$this->admin = new Sharing( |
|||
$this->config |
|||
); |
|||
} |
|||
|
|||
public function testGetFormWithoutExcludedGroups() { |
|||
$this->config |
|||
->expects($this->at(0)) |
|||
->method('getAppValue') |
|||
->with('core', 'shareapi_exclude_groups_list', '') |
|||
->willReturn(''); |
|||
$this->config |
|||
->expects($this->at(1)) |
|||
->method('getAppValue') |
|||
->with('core', 'shareapi_enabled', 'yes') |
|||
->willReturn('yes'); |
|||
$this->config |
|||
->expects($this->at(2)) |
|||
->method('getAppValue') |
|||
->with('core', 'shareapi_default_expire_date', 'no') |
|||
->willReturn('no'); |
|||
$this->config |
|||
->expects($this->at(3)) |
|||
->method('getAppValue') |
|||
->with('core', 'shareapi_expire_after_n_days', '7') |
|||
->willReturn('7'); |
|||
$this->config |
|||
->expects($this->at(4)) |
|||
->method('getAppValue') |
|||
->with('core', 'shareapi_enforce_expire_date', 'no') |
|||
->willReturn('no'); |
|||
$this->config |
|||
->expects($this->at(5)) |
|||
->method('getAppValue') |
|||
->with('core', 'shareapi_exclude_groups', 'no') |
|||
->willReturn('no'); |
|||
|
|||
$expected = new TemplateResponse( |
|||
'settings', |
|||
'admin/sharing', |
|||
[ |
|||
'shareAPIEnabled' => 'yes', |
|||
'shareDefaultExpireDateSet' => 'no', |
|||
'shareExpireAfterNDays' => '7', |
|||
'shareEnforceExpireDate' => 'no', |
|||
'shareExcludeGroups' => false, |
|||
'shareExcludedGroupsList' => '', |
|||
], |
|||
'' |
|||
); |
|||
|
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetFormWithExcludedGroups() { |
|||
$this->config |
|||
->expects($this->at(0)) |
|||
->method('getAppValue') |
|||
->with('core', 'shareapi_exclude_groups_list', '') |
|||
->willReturn('["NoSharers","OtherNoSharers"]'); |
|||
$this->config |
|||
->expects($this->at(1)) |
|||
->method('getAppValue') |
|||
->with('core', 'shareapi_enabled', 'yes') |
|||
->willReturn('yes'); |
|||
$this->config |
|||
->expects($this->at(2)) |
|||
->method('getAppValue') |
|||
->with('core', 'shareapi_default_expire_date', 'no') |
|||
->willReturn('no'); |
|||
$this->config |
|||
->expects($this->at(3)) |
|||
->method('getAppValue') |
|||
->with('core', 'shareapi_expire_after_n_days', '7') |
|||
->willReturn('7'); |
|||
$this->config |
|||
->expects($this->at(4)) |
|||
->method('getAppValue') |
|||
->with('core', 'shareapi_enforce_expire_date', 'no') |
|||
->willReturn('no'); |
|||
$this->config |
|||
->expects($this->at(5)) |
|||
->method('getAppValue') |
|||
->with('core', 'shareapi_exclude_groups', 'no') |
|||
->willReturn('yes'); |
|||
|
|||
$expected = new TemplateResponse( |
|||
'settings', |
|||
'admin/sharing', |
|||
[ |
|||
'shareAPIEnabled' => 'yes', |
|||
'shareDefaultExpireDateSet' => 'no', |
|||
'shareExpireAfterNDays' => '7', |
|||
'shareEnforceExpireDate' => 'no', |
|||
'shareExcludeGroups' => true, |
|||
'shareExcludedGroupsList' => 'NoSharers|OtherNoSharers', |
|||
], |
|||
'' |
|||
); |
|||
|
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetSection() { |
|||
$this->assertSame('sharing', $this->admin->getSection()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(0, $this->admin->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,91 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace Test\Settings\Admin; |
|||
|
|||
use OC\Settings\Admin\TipsTricks; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\IConfig; |
|||
use Test\TestCase; |
|||
|
|||
class TipsTrickTest extends TestCase { |
|||
/** @var TipsTricks */ |
|||
private $admin; |
|||
/** @var IConfig */ |
|||
private $config; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
$this->config = $this->createMock('\OCP\IConfig'); |
|||
|
|||
$this->admin = new TipsTricks( |
|||
$this->config |
|||
); |
|||
} |
|||
|
|||
public function testGetFormWithExcludedGroupsWithSQLite() { |
|||
$this->config |
|||
->expects($this->once()) |
|||
->method('getSystemValue') |
|||
->with('dbtype') |
|||
->willReturn('sqlite'); |
|||
|
|||
$expected = new TemplateResponse( |
|||
'settings', |
|||
'admin/tipstricks', |
|||
[ |
|||
'databaseOverload' => true, |
|||
], |
|||
'' |
|||
); |
|||
|
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetFormWithExcludedGroupsWithoutSQLite() { |
|||
$this->config |
|||
->expects($this->once()) |
|||
->method('getSystemValue') |
|||
->with('dbtype') |
|||
->willReturn('mysql'); |
|||
|
|||
$expected = new TemplateResponse( |
|||
'settings', |
|||
'admin/tipstricks', |
|||
[ |
|||
'databaseOverload' => false, |
|||
], |
|||
'' |
|||
); |
|||
|
|||
$this->assertEquals($expected, $this->admin->getForm()); |
|||
} |
|||
|
|||
public function testGetSection() { |
|||
$this->assertSame('tips-tricks', $this->admin->getSection()); |
|||
} |
|||
|
|||
public function testGetPriority() { |
|||
$this->assertSame(0, $this->admin->getPriority()); |
|||
} |
|||
} |
|||
@ -0,0 +1,220 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace Tests\Settings; |
|||
|
|||
use OC\Settings\Admin\Sharing; |
|||
use OC\Settings\Manager; |
|||
use OC\Settings\Section; |
|||
use OCP\Encryption\IManager; |
|||
use OCP\IConfig; |
|||
use OCP\IDBConnection; |
|||
use OCP\IL10N; |
|||
use OCP\ILogger; |
|||
use OCP\IUserManager; |
|||
use OCP\Lock\ILockingProvider; |
|||
use Test\TestCase; |
|||
|
|||
class ManagerTest extends TestCase { |
|||
/** @var Manager */ |
|||
private $manager; |
|||
/** @var ILogger */ |
|||
private $logger; |
|||
/** @var IDBConnection */ |
|||
private $dbConnection; |
|||
/** @var IL10N */ |
|||
private $l10n; |
|||
/** @var IConfig */ |
|||
private $config; |
|||
/** @var IManager */ |
|||
private $encryptionManager; |
|||
/** @var IUserManager */ |
|||
private $userManager; |
|||
/** @var ILockingProvider */ |
|||
private $lockingProvider; |
|||
|
|||
public function setUp() { |
|||
parent::setUp(); |
|||
|
|||
$this->logger = $this->createMock('\OCP\ILogger'); |
|||
$this->dbConnection = $this->createMock('\OCP\IDBConnection'); |
|||
$this->l10n = $this->createMock('\OCP\IL10N'); |
|||
$this->config = $this->createMock('\OCP\IConfig'); |
|||
$this->encryptionManager = $this->createMock('\OCP\Encryption\IManager'); |
|||
$this->userManager = $this->createMock('\OCP\IUserManager'); |
|||
$this->lockingProvider = $this->createMock('\OCP\Lock\ILockingProvider'); |
|||
|
|||
$this->manager = new Manager( |
|||
$this->logger, |
|||
$this->dbConnection, |
|||
$this->l10n, |
|||
$this->config, |
|||
$this->encryptionManager, |
|||
$this->userManager, |
|||
$this->lockingProvider |
|||
); |
|||
} |
|||
|
|||
public function testSetupSettings() { |
|||
$qb = $this->createMock('\OCP\DB\QueryBuilder\IQueryBuilder'); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('select') |
|||
->with('class') |
|||
->willReturn($qb); |
|||
$this->dbConnection |
|||
->expects($this->at(0)) |
|||
->method('getQueryBuilder') |
|||
->willReturn($qb); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('from') |
|||
->with('admin_settings') |
|||
->willReturn($qb); |
|||
$expressionBuilder = $this->createMock('\OCP\DB\QueryBuilder\IExpressionBuilder'); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('expr') |
|||
->willReturn($expressionBuilder); |
|||
$param = $this->createMock('\OCP\DB\QueryBuilder\IParameter'); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('createNamedParameter') |
|||
->with('OCA\Files\Settings\Admin') |
|||
->willReturn($param); |
|||
$expressionBuilder |
|||
->expects($this->once()) |
|||
->method('eq') |
|||
->with('class', $param) |
|||
->willReturn('myString'); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('where') |
|||
->with('myString') |
|||
->willReturn($qb); |
|||
$stmt = $this->createMock('\Doctrine\DBAL\Driver\Statement'); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('execute') |
|||
->willReturn($stmt); |
|||
|
|||
$qb1 = $this->createMock('\OCP\DB\QueryBuilder\IQueryBuilder'); |
|||
$qb1 |
|||
->expects($this->once()) |
|||
->method('insert') |
|||
->with('admin_settings') |
|||
->willReturn($qb1); |
|||
$this->dbConnection |
|||
->expects($this->at(1)) |
|||
->method('getQueryBuilder') |
|||
->willReturn($qb1); |
|||
|
|||
$this->manager->setupSettings([ |
|||
'admin' => 'OCA\Files\Settings\Admin', |
|||
]); |
|||
} |
|||
|
|||
public function testGetAdminSections() { |
|||
$qb = $this->createMock('\OCP\DB\QueryBuilder\IQueryBuilder'); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('select') |
|||
->with(['class', 'priority']) |
|||
->willReturn($qb); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('from') |
|||
->with('admin_sections') |
|||
->willReturn($qb); |
|||
$stmt = $this->createMock('\Doctrine\DBAL\Driver\Statement'); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('execute') |
|||
->willReturn($stmt); |
|||
$this->dbConnection |
|||
->expects($this->once()) |
|||
->method('getQueryBuilder') |
|||
->willReturn($qb); |
|||
$this->l10n |
|||
->expects($this->any()) |
|||
->method('t') |
|||
->will($this->returnArgument(0)); |
|||
|
|||
$this->assertEquals([ |
|||
0 => [new Section('server', 'Server settings', 0)], |
|||
5 => [new Section('sharing', 'Sharing', 0)], |
|||
45 => [new Section('encryption', 'Encryption', 0)], |
|||
90 => [new Section('logging', 'Logging', 0)], |
|||
98 => [new Section('additional', 'Additional settings', 0)], |
|||
99 => [new Section('tips-tricks', 'Tips & tricks', 0)], |
|||
], $this->manager->getAdminSections()); |
|||
} |
|||
|
|||
public function testGetAdminSettings() { |
|||
$qb = $this->createMock('\OCP\DB\QueryBuilder\IQueryBuilder'); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('select') |
|||
->with(['class', 'priority']) |
|||
->willReturn($qb); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('from') |
|||
->with('admin_settings') |
|||
->willReturn($qb); |
|||
$expressionBuilder = $this->createMock('\OCP\DB\QueryBuilder\IExpressionBuilder'); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('expr') |
|||
->willReturn($expressionBuilder); |
|||
$param = $this->createMock('\OCP\DB\QueryBuilder\IParameter'); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('createParameter') |
|||
->with('section') |
|||
->willReturn($param); |
|||
$expressionBuilder |
|||
->expects($this->once()) |
|||
->method('eq') |
|||
->with('section', $param) |
|||
->willReturn('myString'); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('where') |
|||
->with('myString') |
|||
->willReturn($qb); |
|||
$stmt = $this->createMock('\Doctrine\DBAL\Driver\Statement'); |
|||
$qb |
|||
->expects($this->once()) |
|||
->method('execute') |
|||
->willReturn($stmt); |
|||
$this->dbConnection |
|||
->expects($this->exactly(2)) |
|||
->method('getQueryBuilder') |
|||
->willReturn($qb); |
|||
|
|||
$this->assertEquals([ |
|||
0 => [new Sharing($this->config)], |
|||
], $this->manager->getAdminSettings('sharing')); |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
<?php |
|||
/** |
|||
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @author Lukas Reschke <lukas@statuscode.ch> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace Tests\Settings; |
|||
|
|||
use OC\Settings\Section; |
|||
use Test\TestCase; |
|||
|
|||
class SectionTest extends TestCase { |
|||
public function testGetID() { |
|||
$this->assertSame('ldap', (new Section('ldap', 'name', 1))->getID()); |
|||
} |
|||
public function testGetName() { |
|||
$this->assertSame('name', (new Section('ldap', 'name', 1))->getName()); |
|||
} |
|||
public function testGetPriority() { |
|||
$this->assertSame(1, (new Section('ldap', 'name', 1))->getPriority()); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue