summaryrefslogtreecommitdiff
path: root/tests/LoggrTest.php
diff options
context:
space:
mode:
authorAsko Nõmm <asko@nth.ee>2024-11-15 17:58:47 +0200
committerAsko Nõmm <asko@nth.ee>2024-11-15 17:58:47 +0200
commit0cdfa63b9ce75e5db1e05d2332d6cab667a9f7e1 (patch)
tree314ab8b5d749650d9da362212b7f0e63db38ddba /tests/LoggrTest.php
parentbac7b24d9a1fe3d7b8dd68102794f786f7c43000 (diff)
Implement interpolation
Diffstat (limited to 'tests/LoggrTest.php')
-rw-r--r--tests/LoggrTest.php17
1 files changed, 17 insertions, 0 deletions
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