logger.php 887 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 \PHPUnit_Framework_TestCase {
  11. /**
  12. * @var \OCP\ILogger
  13. */
  14. private $logger;
  15. static private $logs = array();
  16. public function setUp() {
  17. self::$logs = array();
  18. $this->logger = new Log($this);
  19. }
  20. public function testInterpolation() {
  21. $logger = $this->logger;
  22. $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
  23. $expected = array('1 {Message {nothing} Bob Bar a}');
  24. $this->assertEquals($expected, $this->getLogs());
  25. }
  26. private function getLogs() {
  27. return self::$logs;
  28. }
  29. public static function write($app, $message, $level) {
  30. self::$logs[]= "$level $message";
  31. }
  32. }