mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-19 03:11:19 +02:00
Also add setBasePath to NormalizerFormatter/JsonFormatter
This commit is contained in:
@@ -118,6 +118,18 @@ class JsonFormatterTest extends TestCase
|
||||
$this->assertContextContainsFormattedException($formattedException, $message);
|
||||
}
|
||||
|
||||
public function testBasePathWithException(): void
|
||||
{
|
||||
$formatter = new JsonFormatter();
|
||||
$formatter->setBasePath(dirname(dirname(dirname(__DIR__))));
|
||||
$exception = new \RuntimeException('Foo');
|
||||
|
||||
$message = $this->formatRecordWithExceptionInContext($formatter, $exception);
|
||||
|
||||
$parsed = json_decode($message, true);
|
||||
self::assertSame('tests/Monolog/Formatter/JsonFormatterTest.php:' . (__LINE__ - 5), $parsed['context']['exception']['file']);
|
||||
}
|
||||
|
||||
public function testDefFormatWithPreviousException()
|
||||
{
|
||||
$formatter = new JsonFormatter();
|
||||
|
@@ -81,6 +81,20 @@ class NormalizerFormatterTest extends TestCase
|
||||
], $formatted);
|
||||
}
|
||||
|
||||
public function testFormatExceptionWithBasePath(): void
|
||||
{
|
||||
$formatter = new NormalizerFormatter('Y-m-d');
|
||||
$formatter->setBasePath(dirname(dirname(dirname(__DIR__))));
|
||||
$e = new \LogicException('bar');
|
||||
$formatted = $formatter->normalizeValue([
|
||||
'exception' => $e,
|
||||
]);
|
||||
|
||||
self::assertSame('tests/Monolog/Formatter/NormalizerFormatterTest.php:' . (__LINE__ - 5), $formatted['exception']['file']);
|
||||
self::assertStringStartsWith('vendor/phpunit/phpunit/src/Framework/TestCase.php:', $formatted['exception']['trace'][0]);
|
||||
self::assertStringStartsWith('vendor/phpunit/phpunit/src/Framework/TestCase.php:', $formatted['exception']['trace'][1]);
|
||||
}
|
||||
|
||||
public function testFormatSoapFaultException()
|
||||
{
|
||||
if (!class_exists('SoapFault')) {
|
||||
|
Reference in New Issue
Block a user