diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-04-11 14:24:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-11 14:24:47 +0200 |
commit | 7a3ce073dac286eedfa3003c4f8567827cd5f10b (patch) | |
tree | 85eff08ff7778eb06e11dc7689c6705d07232d0d /apps/dav | |
parent | 0dabb26cc2e03e4aa96665fab28c02bb61132cad (diff) | |
parent | 15815c034f8f3720208e492713c79df8b0bc6e46 (diff) | |
download | nextcloud-server-7a3ce073dac286eedfa3003c4f8567827cd5f10b.tar.gz nextcloud-server-7a3ce073dac286eedfa3003c4f8567827cd5f10b.zip |
Merge pull request #8946 from nextcloud/log-exceptions-as-nested-array-2
Log exceptions as nested array instead of encoded json
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php index ff928ccede4..c1d48a7ce5d 100644 --- a/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/ExceptionLoggerPluginTest.php @@ -24,6 +24,7 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre; +use OC\SystemConfig; use OCA\DAV\Connector\Sabre\Exception\InvalidPath; use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin as PluginToTest; use OC\Log; @@ -37,13 +38,9 @@ class TestLogger extends Log { public $message; public $level; - public function __construct($logger = null) { - //disable original constructor - } - - public function log(int $level, string $message, array $context = array()) { + public function writeLog(string $app, $entry, int $level) { $this->level = $level; - $this->message = $message; + $this->message = $entry; } } @@ -59,8 +56,20 @@ class ExceptionLoggerPluginTest extends TestCase { private $logger; private function init() { + $config = $this->createMock(SystemConfig::class); + $config->expects($this->any()) + ->method('getValue') + ->willReturnCallback(function($key, $default) { + switch ($key) { + case 'loglevel': + return 0; + default: + return $default; + } + }); + $this->server = new Server(); - $this->logger = new TestLogger(); + $this->logger = new TestLogger(Log\File::class, $config); $this->plugin = new PluginToTest('unit-test', $this->logger); $this->plugin->initialize($this->server); } @@ -73,7 +82,8 @@ class ExceptionLoggerPluginTest extends TestCase { $this->plugin->logException($exception); $this->assertEquals($expectedLogLevel, $this->logger->level); - $this->assertStringStartsWith('Exception: {"Exception":' . json_encode(get_class($exception)) . ',"Message":"' . $expectedMessage . '",', $this->logger->message); + $this->assertEquals(get_class($exception), $this->logger->message['Exception']); + $this->assertEquals($expectedMessage, $this->logger->message['Message']); } public function providesExceptions() { |