summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-05-12 16:40:58 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-05-12 16:40:58 +0200
commit1d18fd4e6da16895ac1ef879c7b416f555bb385d (patch)
treead875f49b5e73ad8df99e269c84da22498ec894c /tests/lib
parent9a9665f361c42764f5ae9f5f3ce63f71fdfcad5c (diff)
parent93dbb39e775bf599f19445b27a10b0862cc3bab8 (diff)
downloadnextcloud-server-1d18fd4e6da16895ac1ef879c7b416f555bb385d.tar.gz
nextcloud-server-1d18fd4e6da16895ac1ef879c7b416f555bb385d.zip
Merge pull request #8482 from owncloud/public-logger
Make logger available in the container
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/logger.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/lib/logger.php b/tests/lib/logger.php
new file mode 100644
index 00000000000..7d5d4049b28
--- /dev/null
+++ b/tests/lib/logger.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Copyright (c) 2014 Thomas Müller <thomas.mueller@tmit.eu>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test;
+
+use OC\Log;
+
+class Logger extends \PHPUnit_Framework_TestCase {
+ /**
+ * @var \OCP\ILogger
+ */
+ private $logger;
+ static private $logs = array();
+
+ public function setUp() {
+ self::$logs = array();
+ $this->logger = new Log($this);
+ }
+
+ public function testInterpolation() {
+ $logger = $this->logger;
+ $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
+
+ $expected = array('1 {Message {nothing} Bob Bar a}');
+ $this->assertEquals($expected, $this->getLogs());
+ }
+
+ private function getLogs() {
+ return self::$logs;
+ }
+
+ public static function write($app, $message, $level) {
+ self::$logs[]= "$level $message";
+ }
+}