From 6c5f982734436a761c4f4e1c968bb13f3d97f983 Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Fri, 15 Nov 2024 18:04:47 +0200 Subject: Add more interpolation tests --- tests/LoggrTest.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/LoggrTest.php b/tests/LoggrTest.php index 2172907..e217cf4 100644 --- a/tests/LoggrTest.php +++ b/tests/LoggrTest.php @@ -39,4 +39,44 @@ class LoggrTest extends TestCase $loggr = new Loggr(new OutputDriver()); $loggr->info('test {nested.interpolation}', ['nested' => ['interpolation' => 'something']]); } + + public function testIntegerInterpolation(): void + { + $full_date = (new DateTime())->format('Y-m-d H:i:s'); + $this->expectOutputString("[{$full_date}] LoggrTest.INFO: test 1234567890 - {\"integer\":1234567890}"); + $loggr = new Loggr(new OutputDriver()); + $loggr->info('test {integer}', ['integer' => 1234567890]); + } + + public function testBooleanInterpolation(): void + { + $full_date = (new DateTime())->format('Y-m-d H:i:s'); + $this->expectOutputString("[{$full_date}] LoggrTest.INFO: test 1 - {\"boolean\":true}"); + $loggr = new Loggr(new OutputDriver()); + $loggr->info('test {boolean}', ['boolean' => true]); + } + + public function testDoubleInterpolation(): void + { + $full_date = (new DateTime())->format('Y-m-d H:i:s'); + $this->expectOutputString("[{$full_date}] LoggrTest.INFO: test 1234567890.1235 - {\"double\":1234567890.1234567}"); + $loggr = new Loggr(new OutputDriver()); + $loggr->info('test {double}', ['double' => 1234567890.1234567]); + } + + public function testNullInterpolation(): void + { + $full_date = (new DateTime())->format('Y-m-d H:i:s'); + $this->expectOutputString("[{$full_date}] LoggrTest.INFO: test null - {\"null\":null}"); + $loggr = new Loggr(new OutputDriver()); + $loggr->info('test {null}', ['null' => null]); + } + + public function testObjectInterpolation(): void + { + $full_date = (new DateTime())->format('Y-m-d H:i:s'); + $this->expectOutputString("[{$full_date}] LoggrTest.INFO: test test - {\"object\":{\"test\":\"test\"}}"); + $loggr = new Loggr(new OutputDriver()); + $loggr->info('test {object.test}', ['object' => (object) ['test' => 'test']]); + } } \ No newline at end of file -- cgit v1.2.3