mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-11 23:54:04 +02:00
Merge branch '1.x'
This commit is contained in:
@@ -412,46 +412,7 @@ class NormalizerFormatterTest extends TestCase
|
||||
$result = $formatter->format($record);
|
||||
|
||||
$this->assertSame(
|
||||
'{"function":"Monolog\\\\Formatter\\\\{closure}","class":"Monolog\\\\Formatter\\\\NormalizerFormatterTest","type":"->","args":["[object] (Monolog\\\\Formatter\\\\TestFooNorm)","[resource(stream)]"]}',
|
||||
$result['context']['exception']['trace'][0]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test was copied from `testExceptionTraceWithArgs` in order to ensure that pretty prints works
|
||||
*/
|
||||
public function testPrettyPrint()
|
||||
{
|
||||
try {
|
||||
// This will contain $resource and $wrappedResource as arguments in the trace item
|
||||
$resource = fopen('php://memory', 'rw+');
|
||||
fwrite($resource, 'test_resource');
|
||||
$wrappedResource = new TestFooNorm;
|
||||
$wrappedResource->foo = $resource;
|
||||
// Just do something stupid with a resource/wrapped resource as argument
|
||||
$arr = [$wrappedResource, $resource];
|
||||
// modifying the array inside throws a "usort(): Array was modified by the user comparison function"
|
||||
usort($arr, function ($a, $b) {
|
||||
throw new \ErrorException('Foo');
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
|
||||
$formatter = new NormalizerFormatter();
|
||||
$record = ['context' => ['exception' => $e]];
|
||||
$formatter->setJsonPrettyPrint(true);
|
||||
$result = $formatter->format($record);
|
||||
|
||||
$this->assertSame(
|
||||
'{
|
||||
"function": "Monolog\\\\Formatter\\\\{closure}",
|
||||
"class": "Monolog\\\\Formatter\\\\NormalizerFormatterTest",
|
||||
"type": "->",
|
||||
"args": [
|
||||
"[object] (Monolog\\\\Formatter\\\\TestFooNorm)",
|
||||
"[resource(stream)]"
|
||||
]
|
||||
}',
|
||||
__FILE__.':'.(__LINE__-9),
|
||||
$result['context']['exception']['trace'][0]
|
||||
);
|
||||
}
|
||||
@@ -489,7 +450,7 @@ class NormalizerFormatterTest extends TestCase
|
||||
$result = $formatter->format($record);
|
||||
|
||||
$this->assertSame(
|
||||
'{"function":"throwHelper","class":"Monolog\\\\Formatter\\\\NormalizerFormatterTest","type":"->","args":["[object] (Monolog\\\\Formatter\\\\TestInfoLeak)","'.$dt->format('Y-m-d\TH:i:sP').'"]}',
|
||||
__FILE__ .':'.(__LINE__-9),
|
||||
$result['context']['exception']['trace'][0]
|
||||
);
|
||||
}
|
||||
|
@@ -29,8 +29,6 @@ class ScalarFormatterTest extends \PHPUnit\Framework\TestCase
|
||||
foreach ($trace as $frame) {
|
||||
if (isset($frame['file'])) {
|
||||
$data[] = $frame['file'].':'.$frame['line'];
|
||||
} else {
|
||||
$data[] = json_encode($frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user