From f2792852325a68f6a197403077bf6975be186acf Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 11 May 2020 22:18:29 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20tests,=20invalid=20UTF-8=20is=20now=20ret?= =?UTF-8?q?urning=20=EF=BF=BDs=20instead=20of=20being=20converted=20to=20p?= =?UTF-8?q?ossibly=20valid=20ISO-8559-15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Monolog/Formatter/LogstashFormatterTest.php | 2 +- tests/Monolog/Formatter/NormalizerFormatterTest.php | 8 +++----- tests/Monolog/Handler/RotatingFileHandlerTest.php | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/tests/Monolog/Formatter/LogstashFormatterTest.php b/tests/Monolog/Formatter/LogstashFormatterTest.php index b242d680..07a7efe2 100644 --- a/tests/Monolog/Formatter/LogstashFormatterTest.php +++ b/tests/Monolog/Formatter/LogstashFormatterTest.php @@ -176,6 +176,6 @@ class LogstashFormatterTest extends TestCase $this->assertEquals('ERROR', $message['level']); $this->assertEquals('test', $message['type']); $this->assertEquals('hostname', $message['host']); - $this->assertEquals('ÖWN; FBCR/OrangeEspaña; Versão/4.0; Färist', $message['extra']['user_agent']); + $this->assertEquals('�WN; FBCR/OrangeEspa�a; Vers�o/4.0; F�rist', $message['extra']['user_agent']); } } diff --git a/tests/Monolog/Formatter/NormalizerFormatterTest.php b/tests/Monolog/Formatter/NormalizerFormatterTest.php index d3661c5a..9ea7f080 100644 --- a/tests/Monolog/Formatter/NormalizerFormatterTest.php +++ b/tests/Monolog/Formatter/NormalizerFormatterTest.php @@ -270,7 +270,7 @@ class NormalizerFormatterTest extends TestCase $this->assertEquals('Over 1000 items (2000 total), aborting normalization', $res['context'][0]['...']); } - public function testThrowsOnInvalidEncoding() + public function testIgnoresInvalidEncoding() { $formatter = new NormalizerFormatter(); $reflMethod = new \ReflectionMethod($formatter, 'toJson'); @@ -280,9 +280,7 @@ class NormalizerFormatterTest extends TestCase $record = new \stdClass; $record->message = "\xB1\x31"; - $this->expectException(\RuntimeException::class); - - $reflMethod->invoke($formatter, $record); + $this->assertsame('{"message":"�1"}', $reflMethod->invoke($formatter, $record)); } public function testConvertsInvalidEncodingAsLatin9() @@ -293,7 +291,7 @@ class NormalizerFormatterTest extends TestCase $res = $reflMethod->invoke($formatter, ['message' => "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE"]); - $this->assertSame('{"message":"€ŠšŽžŒœŸ"}', $res); + $this->assertSame('{"message":"��������"}', $res); } public function testMaxNormalizeDepth() diff --git a/tests/Monolog/Handler/RotatingFileHandlerTest.php b/tests/Monolog/Handler/RotatingFileHandlerTest.php index 75bcab30..5446f40e 100644 --- a/tests/Monolog/Handler/RotatingFileHandlerTest.php +++ b/tests/Monolog/Handler/RotatingFileHandlerTest.php @@ -137,7 +137,7 @@ class RotatingFileHandlerTest extends TestCase $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2); if (!$valid) { $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessageRegExp('~^Invalid date format~'); + $this->expectExceptionMessageMatches('~^Invalid date format~'); } $handler->setFilenameFormat('{filename}-{date}', $dateFormat); $this->assertTrue(true); @@ -178,7 +178,7 @@ class RotatingFileHandlerTest extends TestCase $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2); if (!$valid) { $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessageRegExp('~^Invalid filename format~'); + $this->expectExceptionMessageMatches('~^Invalid filename format~'); } $handler->setFilenameFormat($filenameFormat, RotatingFileHandler::FILE_PER_DAY);