diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-05-12 14:16:54 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-05-12 14:17:36 +0200 |
commit | 93dbb39e775bf599f19445b27a10b0862cc3bab8 (patch) | |
tree | 917a06feca009cc2a7eb7b0f8b2c238b189bccf5 /tests | |
parent | 9d95fff427e5f09e5a31b9da7b85ca852688851d (diff) | |
download | nextcloud-server-93dbb39e775bf599f19445b27a10b0862cc3bab8.tar.gz nextcloud-server-93dbb39e775bf599f19445b27a10b0862cc3bab8.zip |
adding unit test for message interpolation
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/logger.php | 40 |
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"; + } +} |