mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-11 15:44:34 +02:00
Merge pull request #674 from xapon/tostring-error
#673 Fix fatal error while normalizing with __toString method
This commit is contained in:
@@ -78,6 +78,15 @@ class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
), $formatted);
|
||||
}
|
||||
|
||||
public function testFormatToStringExceptionHandle()
|
||||
{
|
||||
$formatter = new NormalizerFormatter('Y-m-d');
|
||||
$this->setExpectedException('RuntimeException', 'Could not convert to string');
|
||||
$formatter->format(array(
|
||||
'myObject' => new TestToStringError(),
|
||||
));
|
||||
}
|
||||
|
||||
public function testBatchFormat()
|
||||
{
|
||||
$formatter = new NormalizerFormatter('Y-m-d');
|
||||
@@ -268,3 +277,11 @@ class TestStreamFoo
|
||||
return $this->foo . ' - ' . (string) stream_get_contents($this->resource);
|
||||
}
|
||||
}
|
||||
|
||||
class TestToStringError
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
throw new \RuntimeException('Could not convert to string');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user