+++ /dev/null
-<?php
-/**
- * @author Georg Ehrke
- * @copyright 2014 Georg Ehrke <georg@ownCloud.com>
- *
- * 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']);
- }
-}
+++ /dev/null
-<?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->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());
- }
-}
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());