22
33namespace Stefna \Logger \Processor ;
44
5+ use Monolog \Level ;
6+ use Monolog \LogRecord ;
57use PHPUnit \Framework \TestCase ;
68use Psr \Log \LoggerInterface ;
79use Psr \Log \LogLevel ;
@@ -61,6 +63,32 @@ public function testCallbackValueIsRemoved(): void
6163 $ this ->assertTrue ($ callbackExecuted );
6264 }
6365
66+ public function testStringCallbacksBeingSkipped (): void
67+ {
68+ $ processor = new CallableContextProcessor ();
69+
70+ $ logRecord = new LogRecord (
71+ new \DateTimeImmutable (),
72+ 'test ' ,
73+ Level::Alert,
74+ 'message ' ,
75+ [
76+ 'nativeFunction ' => 'header ' ,
77+ 'namespacedFunction ' => 'Stefna\Logger\Processor\testingFunction ' ,
78+ 'deferredValue ' => function () {
79+ return 'complexValue ' ;
80+ }
81+ ],
82+ );
83+
84+ $ modifiedContext = $ processor ($ logRecord );
85+ $ this ->assertSame ([
86+ 'nativeFunction ' => 'header ' ,
87+ 'namespacedFunction ' => 'Stefna\Logger\Processor\testingFunction ' ,
88+ 'deferredValue ' => 'complexValue ' ,
89+ ], $ modifiedContext ->context );
90+ }
91+
6492 public function testStringFunctionIsNotCalled ():void
6593 {
6694 $ stringFunction = 'Stefna\Logger\Processor\testingFunction ' ;
@@ -82,7 +110,7 @@ public function testStringFunctionIsNotCalled():void
82110 }
83111}
84112
85- function testingFunction ()
113+ function testingFunction (): never
86114{
87- print ( " should not print this " );
115+ CallableContextTest:: fail ( " Shouldn't be called " );
88116}
0 commit comments