1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-07-31 02:10:22 +02:00

Add test for setBasePath functionality, refs #1873

This commit is contained in:
Jordi Boggiano
2024-04-12 22:41:20 +02:00
parent 24e0e454d9
commit 84638a5926

View File

@@ -292,6 +292,19 @@ class LineFormatterTest extends TestCase
$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
{