From 84638a5926710c1db58ddc68e26aae2b75e345c6 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 12 Apr 2024 22:41:20 +0200 Subject: [PATCH] Add test for setBasePath functionality, refs #1873 --- tests/Monolog/Formatter/LineFormatterTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Monolog/Formatter/LineFormatterTest.php b/tests/Monolog/Formatter/LineFormatterTest.php index 09b4f7673..ab31c64f4 100644 --- a/tests/Monolog/Formatter/LineFormatterTest.php +++ b/tests/Monolog/Formatter/LineFormatterTest.php @@ -292,6 +292,19 @@ public function testIndentStackTraces(): void $this->assertStringContainsString(' #1', $message); } + public function testBasePath(): void + { + $formatter = new LineFormatter(); + $formatter->includeStacktraces(); + $formatter->setBasePath(dirname(dirname(dirname(__DIR__)))); + $formatter->indentStackTraces(' '); + $message = $formatter->format($this->getRecord(message: "foo", context: ['exception' => new RuntimeException('lala')])); + + $this->assertStringContainsString(' [stacktrace]', $message); + $this->assertStringContainsString(' #0 vendor/phpunit/phpunit/src/Framework/TestCase.php', $message); + $this->assertStringContainsString(' #1 vendor/phpunit/phpunit/', $message); + } + #[DataProvider('providerMaxLevelNameLength')] public function testMaxLevelNameLength(?int $maxLength, Level $logLevel, string $expectedLevelName): void {