logger.php 899 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Copyright (c) 2014 Thomas Müller <thomas.mueller@tmit.eu>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace Test;
  9. use OC\Log;
  10. class Logger extends TestCase {
  11. /**
  12. * @var \OCP\ILogger
  13. */
  14. private $logger;
  15. static private $logs = array();
  16. protected function setUp() {
  17. parent::setUp();
  18. self::$logs = array();
  19. $this->logger = new Log('Test\Logger');
  20. }
  21. public function testInterpolation() {
  22. $logger = $this->logger;
  23. $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
  24. $expected = array('1 {Message {nothing} Bob Bar a}');
  25. $this->assertEquals($expected, $this->getLogs());
  26. }
  27. private function getLogs() {
  28. return self::$logs;
  29. }
  30. public static function write($app, $message, $level) {
  31. self::$logs[]= "$level $message";
  32. }
  33. }