mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-03 03:37:34 +02:00
Calculate exception message according to PHP version (#1644)
This commit is contained in:
@@ -145,7 +145,25 @@ class StreamHandlerTest extends TestCase
|
|||||||
public function testWriteInvalidResource()
|
public function testWriteInvalidResource()
|
||||||
{
|
{
|
||||||
$this->expectException(\UnexpectedValueException::class);
|
$this->expectException(\UnexpectedValueException::class);
|
||||||
$this->expectExceptionMessage('The stream or file "bogus://url" could not be opened in append mode: Failed to open stream: No such file or directory'."\n".'The exception occurred while attempting to log: test'."\n".'Context: {"foo":"bar"}'."\n".'Extra: [1,2,3]');
|
$php7xMessage = <<<STRING
|
||||||
|
The stream or file "bogus://url" could not be opened in append mode: failed to open stream: No such file or directory
|
||||||
|
The exception occurred while attempting to log: test
|
||||||
|
Context: {"foo":"bar"}
|
||||||
|
Extra: [1,2,3]
|
||||||
|
STRING;
|
||||||
|
|
||||||
|
$php8xMessage = <<<STRING
|
||||||
|
The stream or file "bogus://url" could not be opened in append mode: Failed to open stream: No such file or directory
|
||||||
|
The exception occurred while attempting to log: test
|
||||||
|
Context: {"foo":"bar"}
|
||||||
|
Extra: [1,2,3]
|
||||||
|
STRING;
|
||||||
|
|
||||||
|
$phpVersionString = phpversion();
|
||||||
|
$phpVersionComponents = explode('.', $phpVersionString);
|
||||||
|
$majorVersion = (int) $phpVersionComponents[0];
|
||||||
|
|
||||||
|
$this->expectExceptionMessage(($majorVersion >= 8) ? $php8xMessage : $php7xMessage);
|
||||||
|
|
||||||
$handler = new StreamHandler('bogus://url');
|
$handler = new StreamHandler('bogus://url');
|
||||||
$record = $this->getRecord();
|
$record = $this->getRecord();
|
||||||
|
Reference in New Issue
Block a user