@@ -11,26 +11,27 @@ class LogTest extends TestCase
1111{
1212 use LoggerAttributeTrait;
1313
14- private Log $ log ;
15-
1614 public function test_default_setup ()
1715 {
18- $ this ->assertSame ('d/m/Y H:i:s.u ' , $ this ->property ($ this ->log , 'dateformat ' ));
19- $ this ->assertSame ('UTC ' , $ this ->property ($ this ->log , 'timezone ' )->getName ());
16+ $ log = new Log ;
2017
21- $ this ->assertEmpty ($ this ->property ($ this ->log , 'processors ' ));
18+ $ this ->assertSame ('d/m/Y H:i:s.u ' , $ this ->property ($ log , 'dateformat ' ));
19+ $ this ->assertSame ('UTC ' , $ this ->property ($ log , 'timezone ' )->getName ());
20+ $ this ->assertEmpty ($ this ->property ($ log , 'processors ' ));
2221 }
2322
2423 public function test_attach_and_detach ()
2524 {
25+ $ log = new Log ;
2626 $ processor = new Memory ([]);
27- $ this ->assertCount (0 , $ this ->property ($ this ->log , 'processors ' ));
2827
29- $ this ->log ->attach ($ processor );
30- $ this ->assertCount (1 , $ this ->property ($ this ->log , 'processors ' ));
28+ $ this ->assertCount (0 , $ this ->property ($ log , 'processors ' ));
29+
30+ $ log ->attach ($ processor );
31+ $ this ->assertCount (1 , $ this ->property ($ log , 'processors ' ));
3132
32- $ this -> log ->detach ($ processor );
33- $ this ->assertCount (0 , $ this ->property ($ this -> log , 'processors ' ));
33+ $ log ->detach ($ processor );
34+ $ this ->assertCount (0 , $ this ->property ($ log , 'processors ' ));
3435 }
3536
3637 public function test_log_suppression ()
@@ -53,15 +54,27 @@ public function test_log_suppression()
5354
5455 public function test_exception ()
5556 {
57+ $ log = new Log ;
58+
5659 $ processor = new Memory ([]);
57- $ this -> log ->exception (new Exception ('The error message ' , 1 ), $ processor );
60+ $ log ->exception (new Exception ('The error message ' , 1 ), $ processor );
5861
5962 $ this ->assertStringContainsString ('[CRITICAL] ' , $ this ->property ($ processor , 'formatted ' ));
6063 $ this ->assertStringContainsString ('The error message ' , $ this ->property ($ processor , 'formatted ' ));
6164 }
6265
63- protected function setUp (): void
66+ public function test_log_level ()
6467 {
65- $ this ->log = new Log ([]);
68+ $ log = new Log ;
69+ $ processor = new Memory ([]);
70+ $ log ->attach ($ processor );
71+
72+ $ log ->log ('TESTING ' , 'Hello {u} ' , ['u ' => 'Universe ' ]);
73+
74+ $ this ->assertStringContainsString (
75+ '[LOG] Hello Universe ' ,
76+ $ processor ->formatted (),
77+ 'The unknown level is defaulted to "LOG" '
78+ );
6679 }
6780}
0 commit comments