From 0048b3aa2e70b2e9d2f1fbb6adb82af31b13f95a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 21 Nov 2016 14:14:20 +0100 Subject: [PATCH] update tests Signed-off-by: Robin Appelman --- .../Controller/LogSettingsControllerTest.php | 89 ------------------ tests/lib/Settings/Admin/LoggingTest.php | 91 ------------------- tests/lib/Settings/ManagerTest.php | 1 - 3 files changed, 181 deletions(-) delete mode 100644 tests/Settings/Controller/LogSettingsControllerTest.php delete mode 100644 tests/lib/Settings/Admin/LoggingTest.php diff --git a/tests/Settings/Controller/LogSettingsControllerTest.php b/tests/Settings/Controller/LogSettingsControllerTest.php deleted file mode 100644 index 27ae9328d1f..00000000000 --- a/tests/Settings/Controller/LogSettingsControllerTest.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace Tests\Settings\Controller; - -use \OC\Settings\Application; -use OC\Settings\Controller\LogSettingsController; -use OCP\AppFramework\Http\StreamResponse; -use OCP\IConfig; -use OCP\IL10N; -use OCP\IRequest; - -/** - * @package Tests\Settings\Controller - */ -class LogSettingsControllerTest extends \Test\TestCase { - - /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ - private $config; - - /** @var LogSettingsController */ - private $logSettingsController; - - protected function setUp() { - parent::setUp(); - - $this->config = $this->createMock(IConfig::class); - $l = $this->createMock(IL10N::class); - $l->method('t') - ->will($this->returnCallback(function($text, $parameters = []) { - return vsprintf($text, $parameters); - })); - $this->logSettingsController = new LogSettingsController( - 'settings', - $this->createMock(IRequest::class), - $this->config, - $l - ); - } - - /** - * @dataProvider logLevelData - */ - public function testSetLogLevel($level, $inRange) { - if ($inRange) { - $this->config->expects($this->once()) - ->method('setSystemValue') - ->with('loglevel', $level); - } - - $response = $this->logSettingsController->setLogLevel($level)->getData(); - - if ($inRange) { - $expectedResponse = ['level' => $level]; - } else { - $expectedResponse = ['message' => 'log-level out of allowed range']; - } - - $this->assertSame($expectedResponse, $response); - } - - public function logLevelData() { - return [ - [-1, false], - [0, true], - [1, true], - [2, true], - [3, true], - [4, true], - [5, false], - ]; - } - - public function testDownload() { - $response = $this->logSettingsController->download(); - - $this->assertInstanceOf('\OCP\AppFramework\Http\StreamResponse', $response); - $headers = $response->getHeaders(); - $this->assertEquals('application/octet-stream', $headers['Content-Type']); - $this->assertEquals('attachment; filename="nextcloud.log"', $headers['Content-Disposition']); - } -} diff --git a/tests/lib/Settings/Admin/LoggingTest.php b/tests/lib/Settings/Admin/LoggingTest.php deleted file mode 100644 index 181553d3894..00000000000 --- a/tests/lib/Settings/Admin/LoggingTest.php +++ /dev/null @@ -1,91 +0,0 @@ - - * - * @author Lukas Reschke - * - * @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 . - * - */ - -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->getMockBuilder('\OCP\IConfig')->getMock(); - - $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()); - } -} diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php index 942a2bb63e7..150609499ad 100644 --- a/tests/lib/Settings/ManagerTest.php +++ b/tests/lib/Settings/ManagerTest.php @@ -177,7 +177,6 @@ class ManagerTest extends TestCase { 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()); -- 2.39.5