Odyssey
LoggingTest.php
1 <?php
2 // vim: tabstop=2 expandtab syn=php
3 
4 use PHPUnit\Framework\TestCase;
5 
6 require_once 'logging.i';
7 
8 
9 class TestLogger extends Logger {
10 
11  function log($level, $msg) {
12  return [$level, $msg];
13  }
14 }
15 
16 
17 class LoggingTest extends TestCase {
18 
19  function setUp() {
20  $test = $this;
21  $this->l = new TestLogger();
22  }
23 
24  function test_empty_no_error() {
25  $this->assertEmpty($this->l->debug()[1]);
26  $this->assertEmpty($this->l->info()[1]);
27  $this->assertEmpty($this->l->warning()[1]);
28  $this->assertEmpty($this->l->error()[1]);
29  }
30 
31  function test_simple_arg() {
32  $this->assertEquals($this->l->info('FOO')[1], 'FOO');
33  }
34 
35  function test_printf_args() {
36  $res = $this->l->info('::%s::%d::', 'FOO', 123)[1];
37  $this->assertEquals($res, '::FOO::123::');
38  }
39 }
40 
41 ?>
Definition: logging.i:9