summaryrefslogtreecommitdiff
path: root/tests/LoggrTest.php
diff options
context:
space:
mode:
authorAsko Nõmm <asko@nmm.ee>2025-04-10 11:39:12 +0300
committerAsko Nõmm <asko@nmm.ee>2025-04-10 11:39:12 +0300
commit233bbd9d9262002fbeee96114c08d90a7b45edef (patch)
tree221c950939479e45b7bb58c81584a3e0fa5fa414 /tests/LoggrTest.php
parent38289fea342485943c55bbeaaacd117be7742cc7 (diff)
Fix tests
Diffstat (limited to 'tests/LoggrTest.php')
-rw-r--r--tests/LoggrTest.php67
1 files changed, 43 insertions, 24 deletions
diff --git a/tests/LoggrTest.php b/tests/LoggrTest.php
index 29cdce2..2503609 100644
--- a/tests/LoggrTest.php
+++ b/tests/LoggrTest.php
@@ -12,7 +12,7 @@ class LoggrTest extends TestCase
public function testNoDriver(): void
{
$logger = new Loggr();
- $logger->info('test');
+ $logger->info("test");
$this->assertEquals("Driver or format not set.", $logger->error);
}
@@ -20,63 +20,82 @@ class LoggrTest extends TestCase
{
$logger = new Loggr(new OutputDriver());
$logger->format = null;
- $logger->info('test');
+ $logger->info("test");
$this->assertEquals("Driver or format not set.", $logger->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\"}");
+ $full_date = (new DateTime())->format("Y-m-d H:i:s");
+ $this->expectOutputString(
+ "[$full_date] LoggrTest.INFO: test something {\"interpolation\":\"something\"}" .
+ PHP_EOL
+ );
$logger = new Loggr(new OutputDriver());
- $logger->info('test {interpolation}', ['interpolation' => 'something']);
+ $logger->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\"}}");
+ $full_date = (new DateTime())->format("Y-m-d H:i:s");
+ $this->expectOutputString(
+ "[$full_date] LoggrTest.INFO: test something {\"nested\":{\"interpolation\":\"something\"}}" .
+ PHP_EOL
+ );
$logger = new Loggr(new OutputDriver());
- $logger->info('test {nested.interpolation}', ['nested' => ['interpolation' => 'something']]);
+ $logger->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}");
+ $full_date = (new DateTime())->format("Y-m-d H:i:s");
+ $this->expectOutputString(
+ "[$full_date] LoggrTest.INFO: test 1234567890 {\"integer\":1234567890}" . PHP_EOL
+ );
$logger = new Loggr(new OutputDriver());
- $logger->info('test {integer}', ['integer' => 1234567890]);
+ $logger->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}");
+ $full_date = (new DateTime())->format("Y-m-d H:i:s");
+ $this->expectOutputString(
+ "[$full_date] LoggrTest.INFO: test 1 {\"boolean\":true}" . PHP_EOL
+ );
$logger = new Loggr(new OutputDriver());
- $logger->info('test {boolean}', ['boolean' => true]);
+ $logger->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}");
+ $full_date = (new DateTime())->format("Y-m-d H:i:s");
+ $this->expectOutputString(
+ "[$full_date] LoggrTest.INFO: test 1234567890.1235 {\"double\":1234567890.1234567}" .
+ PHP_EOL
+ );
$logger = new Loggr(new OutputDriver());
- $logger->info('test {double}', ['double' => 1234567890.1234567]);
+ $logger->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}");
+ $full_date = (new DateTime())->format("Y-m-d H:i:s");
+ $this->expectOutputString(
+ "[$full_date] LoggrTest.INFO: test null {\"null\":null}" . PHP_EOL
+ );
$logger = new Loggr(new OutputDriver());
- $logger->info('test {null}', ['null' => null]);
+ $logger->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\"}}");
+ $full_date = (new DateTime())->format("Y-m-d H:i:s");
+ $this->expectOutputString(
+ "[$full_date] LoggrTest.INFO: test test {\"object\":{\"test\":\"test\"}}" . PHP_EOL
+ );
$logger = new Loggr(new OutputDriver());
- $logger->info('test {object.test}', ['object' => (object) ['test' => 'test']]);
+ $logger->info("test {object.test}", ["object" => (object) ["test" => "test"]]);
}
-} \ No newline at end of file
+}