123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?php
- 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/>.
- *
- */
- 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;
- /**
- * @group DB
- */
- class ServerTest extends TestCase {
- /** @var Server */
- private $admin;
- /** @var IDBConnection */
- private $connection;
- /** @var IInitialState */
- private $initialStateService;
- /** @var ProfileManager */
- private $profileManager;
- /** @var ITimeFactory|MockObject */
- private $timeFactory;
- /** @var IConfig|MockObject */
- private $config;
- /** @var IAppConfig|MockObject */
- private $appConfig;
- /** @var IL10N|MockObject */
- private $l10n;
- /** @var IUrlGenerator|MockObject */
- private $urlGenerator;
- protected function setUp(): void {
- parent::setUp();
- $this->connection = \OC::$server->getDatabaseConnection();
- $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();
- }
- public function testGetForm(): void {
- $this->admin->expects($this->once())
- ->method('cronMaxAge')
- ->willReturn(1337);
- $this->config
- ->expects($this->any())
- ->method('getAppValue')
- ->willReturnMap([
- ['core', 'backgroundjobs_mode', 'ajax', 'ajax'],
- ['core', 'lastcron', '0', '0'],
- ['core', 'cronErrors', ''],
- ]);
- $this->profileManager
- ->expects($this->exactly(2))
- ->method('isProfileEnabled')
- ->willReturn(true);
- $expected = new TemplateResponse(
- 'settings',
- 'settings/admin/server',
- [
- 'profileEnabledGlobally' => true,
- ],
- ''
- );
- $this->assertEquals($expected, $this->admin->getForm());
- }
- public function testGetSection(): void {
- $this->assertSame('server', $this->admin->getSection());
- }
- public function testGetPriority(): void {
- $this->assertSame(0, $this->admin->getPriority());
- }
- }
|