From 0cdfa63b9ce75e5db1e05d2332d6cab667a9f7e1 Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Fri, 15 Nov 2024 17:58:47 +0200 Subject: Implement interpolation --- tests/LoggrTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/LoggrTest.php') diff --git a/tests/LoggrTest.php b/tests/LoggrTest.php index a7c3628..2172907 100644 --- a/tests/LoggrTest.php +++ b/tests/LoggrTest.php @@ -4,6 +4,7 @@ namespace Asko\Loggr\Tests; use Asko\Loggr\Drivers\OutputDriver; use Asko\Loggr\Loggr; +use DateTime; use PHPUnit\Framework\TestCase; class LoggrTest extends TestCase @@ -22,4 +23,20 @@ class LoggrTest extends TestCase $loggr->info('test'); $this->assertEquals("Driver or format not set.", $loggr->error); } + + public function testInterpolation(): void + { + $full_date = (new DateTime())->format('Y-m-d H:i:s'); + $this->expectOutputString("[{$full_date}] LoggrTest.INFO: test something - {\"interpolation\":\"something\"}"); + $loggr = new Loggr(new OutputDriver()); + $loggr->info('test {interpolation}', ['interpolation' => 'something']); + } + + public function testNestedInterpolation(): void + { + $full_date = (new DateTime())->format('Y-m-d H:i:s'); + $this->expectOutputString("[{$full_date}] LoggrTest.INFO: test something - {\"nested\":{\"interpolation\":\"something\"}}"); + $loggr = new Loggr(new OutputDriver()); + $loggr->info('test {nested.interpolation}', ['nested' => ['interpolation' => 'something']]); + } } \ No newline at end of file -- cgit v1.2.3