aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/tests/Settings/Admin/ServerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings/tests/Settings/Admin/ServerTest.php')
-rw-r--r--apps/settings/tests/Settings/Admin/ServerTest.php99
1 files changed, 45 insertions, 54 deletions
diff --git a/apps/settings/tests/Settings/Admin/ServerTest.php b/apps/settings/tests/Settings/Admin/ServerTest.php
index f37cb01a40d..e2ca4cff3c6 100644
--- a/apps/settings/tests/Settings/Admin/ServerTest.php
+++ b/apps/settings/tests/Settings/Admin/ServerTest.php
@@ -3,40 +3,21 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-
namespace OCA\Settings\Tests\Settings\Admin;
+use OC\Profile\ProfileManager;
use OCA\Settings\Settings\Admin\Server;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\Services\IInitialState;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IDBConnection;
+use OCP\IL10N;
+use OCP\IUrlGenerator;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@@ -44,27 +25,38 @@ use Test\TestCase;
* @group DB
*/
class ServerTest extends TestCase {
- /** @var Server */
- private $admin;
- /** @var IDBConnection */
- private $connection;
- /** @var ITimeFactory|MockObject */
- private $timeFactory;
- /** @var IConfig|MockObject */
- private $config;
+ private IDBConnection $connection;
+ private Server&MockObject $admin;
+ private IInitialState&MockObject $initialStateService;
+ private ProfileManager&MockObject $profileManager;
+ private ITimeFactory&MockObject $timeFactory;
+ private IConfig&MockObject $config;
+ private IAppConfig&MockObject $appConfig;
+ private IL10N&MockObject $l10n;
+ private IUrlGenerator&MockObject $urlGenerator;
protected function setUp(): void {
parent::setUp();
- $this->connection = \OC::$server->getDatabaseConnection();
+ $this->connection = \OCP\Server::get(IDBConnection::class);
+ $this->initialStateService = $this->createMock(IInitialState::class);
+ $this->profileManager = $this->createMock(ProfileManager::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->config = $this->createMock(IConfig::class);
+ $this->appConfig = $this->createMock(IAppConfig::class);
+ $this->l10n = $this->createMock(IL10N::class);
+ $this->urlGenerator = $this->createMock(IUrlGenerator::class);
$this->admin = $this->getMockBuilder(Server::class)
->onlyMethods(['cronMaxAge'])
->setConstructorArgs([
$this->connection,
+ $this->initialStateService,
+ $this->profileManager,
$this->timeFactory,
+ $this->urlGenerator,
$this->config,
+ $this->appConfig,
+ $this->l10n,
])
->getMock();
}
@@ -74,30 +66,29 @@ class ServerTest extends TestCase {
->method('cronMaxAge')
->willReturn(1337);
$this->config
- ->expects($this->at(0))
- ->method('getAppValue')
- ->with('core', 'backgroundjobs_mode', 'ajax')
- ->willReturn('ajax');
- $this->config
- ->expects($this->at(1))
- ->method('getAppValue')
- ->with('core', 'lastcron', false)
- ->willReturn(false);
- $this->config
- ->expects($this->at(2))
+ ->expects($this->any())
->method('getAppValue')
- ->with('core', 'cronErrors')
- ->willReturn('');
+ ->willReturnMap([
+ ['core', 'lastcron', '0', '0'],
+ ['core', 'cronErrors', ''],
+ ]);
+ $this->appConfig
+ ->expects($this->any())
+ ->method('getValueString')
+ ->willReturnCallback(fn ($a, $b, $default) => $default);
+ $this->appConfig
+ ->expects($this->any())
+ ->method('getValueBool')
+ ->willReturnCallback(fn ($a, $b, $default) => $default);
+ $this->profileManager
+ ->expects($this->exactly(2))
+ ->method('isProfileEnabled')
+ ->willReturn(true);
$expected = new TemplateResponse(
'settings',
'settings/admin/server',
[
- 'backgroundjobs_mode' => 'ajax',
- 'lastcron' => false,
- 'cronErrors' => '',
- 'cronMaxAge' => 1337,
- 'cli_based_cron_possible' => true,
- 'cli_based_cron_user' => function_exists('posix_getpwuid') ? posix_getpwuid(fileowner(\OC::$configDir . 'config.php'))['name'] : '', // to not explode here because of posix extension not being disabled - which is already checked in the line above
+ 'profileEnabledGlobally' => true,
],
''
);