From 2c75de3a4c9365035f342feb6927e7c7614afa9a Mon Sep 17 00:00:00 2001 From: "Maurits van Riezen (mousetail)" Date: Tue, 21 May 2024 16:42:52 +0200 Subject: [PATCH] write tests for the JUnit escaping errors --- src/Testing/ErrorFormatterTestCase.php | 4 ++-- .../BaselineNeonErrorFormatterTest.php | 4 ++-- .../CheckstyleErrorFormatterTest.php | 8 ++++---- .../GithubErrorFormatterTest.php | 8 ++++---- .../ErrorFormatter/GitlabFormatterTest.php | 20 +++++++++---------- .../ErrorFormatter/JsonErrorFormatterTest.php | 8 ++++---- .../JunitErrorFormatterTest.php | 8 ++++---- .../ErrorFormatter/RawErrorFormatterTest.php | 8 ++++---- .../TableErrorFormatterTest.php | 8 ++++---- .../TeamcityErrorFormatterTest.php | 8 ++++---- 10 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/Testing/ErrorFormatterTestCase.php b/src/Testing/ErrorFormatterTestCase.php index f4b90e6778..c3fd17f0b2 100644 --- a/src/Testing/ErrorFormatterTestCase.php +++ b/src/Testing/ErrorFormatterTestCase.php @@ -80,7 +80,7 @@ protected function getAnalysisResult(int $numFileErrors, int $numGenericErrors): $fileErrors = array_slice([ new Error('Foo', self::DIRECTORY_PATH . '/folder with unicode 😃/file name with "spaces" and unicode 😃.php', 4), - new Error('Foo', self::DIRECTORY_PATH . '/foo.php', 1), + new Error('Foo', self::DIRECTORY_PATH . '/foo.php', 1), new Error("Bar\nBar2", self::DIRECTORY_PATH . '/foo.php', 5, true, null, null, 'a tip'), new Error("Bar\nBar2", self::DIRECTORY_PATH . '/folder with unicode 😃/file name with "spaces" and unicode 😃.php', 2), new Error("Bar\nBar2", self::DIRECTORY_PATH . '/foo.php', null), @@ -88,7 +88,7 @@ protected function getAnalysisResult(int $numFileErrors, int $numGenericErrors): $genericErrors = array_slice([ 'first generic error', - 'second generic error', + 'second generic', ], 0, $numGenericErrors); return new AnalysisResult( diff --git a/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php index 01fd649bf0..ac972f04a9 100644 --- a/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/BaselineNeonErrorFormatterTest.php @@ -74,7 +74,7 @@ public function dataFormatterOutputProvider(): iterable 'path' => 'foo.php', ], [ - 'message' => '#^Foo$#', + 'message' => '#^Foo\$#', 'count' => 1, 'path' => 'foo.php', ], @@ -103,7 +103,7 @@ public function dataFormatterOutputProvider(): iterable 'path' => 'foo.php', ], [ - 'message' => '#^Foo$#', + 'message' => '#^Foo\$#', 'count' => 1, 'path' => 'foo.php', ], diff --git a/tests/PHPStan/Command/ErrorFormatter/CheckstyleErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/CheckstyleErrorFormatterTest.php index 0b8593d203..6618b6effe 100644 --- a/tests/PHPStan/Command/ErrorFormatter/CheckstyleErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/CheckstyleErrorFormatterTest.php @@ -64,7 +64,7 @@ public function dataFormatterOutputProvider(): iterable - + @@ -80,7 +80,7 @@ public function dataFormatterOutputProvider(): iterable - + ', @@ -98,12 +98,12 @@ public function dataFormatterOutputProvider(): iterable - + - + ', diff --git a/tests/PHPStan/Command/ErrorFormatter/GithubErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/GithubErrorFormatterTest.php index b6a921e06c..3a93977ce5 100644 --- a/tests/PHPStan/Command/ErrorFormatter/GithubErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/GithubErrorFormatterTest.php @@ -45,7 +45,7 @@ public function dataFormatterOutputProvider(): iterable 0, '::error file=folder with unicode 😃/file name with "spaces" and unicode 😃.php,line=2,col=0::Bar%0ABar2 ::error file=folder with unicode 😃/file name with "spaces" and unicode 😃.php,line=4,col=0::Foo -::error file=foo.php,line=1,col=0::Foo +::error file=foo.php,line=1,col=0::Foo ::error file=foo.php,line=5,col=0::Bar%0ABar2 ', ]; @@ -56,7 +56,7 @@ public function dataFormatterOutputProvider(): iterable 0, 2, '::error ::first generic error -::error ::second generic error +::error ::second generic ', ]; @@ -67,10 +67,10 @@ public function dataFormatterOutputProvider(): iterable 2, '::error file=folder with unicode 😃/file name with "spaces" and unicode 😃.php,line=2,col=0::Bar%0ABar2 ::error file=folder with unicode 😃/file name with "spaces" and unicode 😃.php,line=4,col=0::Foo -::error file=foo.php,line=1,col=0::Foo +::error file=foo.php,line=1,col=0::Foo ::error file=foo.php,line=5,col=0::Bar%0ABar2 ::error ::first generic error -::error ::second generic error +::error ::second generic ', ]; } diff --git a/tests/PHPStan/Command/ErrorFormatter/GitlabFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/GitlabFormatterTest.php index e4d63c28d7..78df3d79dd 100644 --- a/tests/PHPStan/Command/ErrorFormatter/GitlabFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/GitlabFormatterTest.php @@ -88,8 +88,8 @@ public function dataFormatterOutputProvider(): iterable } }, { - "description": "Foo", - "fingerprint": "93c79740ed8c6fbaac2087e54d6f6f67fc0918e3ff77840530f32e19857ef63c", + "description": "Foo", + "fingerprint": "d7002959fc192c81d51fc41b0a3f240617a1aa35361867b5e924ae8d7fec39cb", "severity": "major", "location": { "path": "with space/and unicode \ud83d\ude03/project/foo.php", @@ -152,8 +152,8 @@ public function dataFormatterOutputProvider(): iterable } }, { - "description": "Foo", - "fingerprint": "93c79740ed8c6fbaac2087e54d6f6f67fc0918e3ff77840530f32e19857ef63c", + "description": "Foo", + "fingerprint": "d7002959fc192c81d51fc41b0a3f240617a1aa35361867b5e924ae8d7fec39cb", "severity": "major", "location": { "path": "with space/and unicode \ud83d\ude03/project/foo.php", @@ -194,8 +194,8 @@ public function dataFormatterOutputProvider(): iterable } }, { - "description": "second generic error", - "fingerprint": "f49870714e8ce889212aefb50f718f88ae63d00dd01c775b7bac86c4466e96f0", + "description": "second generic", + "fingerprint": "adc18b2c27b0ecad40aed7975b165cbe357f0cbba58582af91c0a2e7fa5d77ab", "severity": "major", "location": { "path": "", @@ -236,8 +236,8 @@ public function dataFormatterOutputProvider(): iterable } }, { - "description": "Foo", - "fingerprint": "93c79740ed8c6fbaac2087e54d6f6f67fc0918e3ff77840530f32e19857ef63c", + "description": "Foo", + "fingerprint": "d7002959fc192c81d51fc41b0a3f240617a1aa35361867b5e924ae8d7fec39cb", "severity": "major", "location": { "path": "with space/and unicode \ud83d\ude03/project/foo.php", @@ -269,8 +269,8 @@ public function dataFormatterOutputProvider(): iterable } }, { - "description": "second generic error", - "fingerprint": "f49870714e8ce889212aefb50f718f88ae63d00dd01c775b7bac86c4466e96f0", + "description": "second generic", + "fingerprint": "adc18b2c27b0ecad40aed7975b165cbe357f0cbba58582af91c0a2e7fa5d77ab", "severity": "major", "location": { "path": "", diff --git a/tests/PHPStan/Command/ErrorFormatter/JsonErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/JsonErrorFormatterTest.php index c936bf48cc..9a1eca0188 100644 --- a/tests/PHPStan/Command/ErrorFormatter/JsonErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/JsonErrorFormatterTest.php @@ -105,7 +105,7 @@ public function dataFormatterOutputProvider(): iterable "errors":2, "messages":[ { - "message": "Foo", + "message": "Foo", "line": 1, "ignorable": true }, @@ -136,7 +136,7 @@ public function dataFormatterOutputProvider(): iterable "files":[], "errors": [ "first generic error", - "second generic error" + "second generic" ] }', ]; @@ -172,7 +172,7 @@ public function dataFormatterOutputProvider(): iterable "errors":2, "messages":[ { - "message": "Foo", + "message": "Foo", "line": 1, "ignorable": true }, @@ -187,7 +187,7 @@ public function dataFormatterOutputProvider(): iterable }, "errors": [ "first generic error", - "second generic error" + "second generic" ] }', ]; diff --git a/tests/PHPStan/Command/ErrorFormatter/JunitErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/JunitErrorFormatterTest.php index 7a913521ef..f83f162bb2 100644 --- a/tests/PHPStan/Command/ErrorFormatter/JunitErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/JunitErrorFormatterTest.php @@ -74,7 +74,7 @@ public function dataFormatterOutputProvider(): Generator - + @@ -93,7 +93,7 @@ public function dataFormatterOutputProvider(): Generator - + ', @@ -112,7 +112,7 @@ public function dataFormatterOutputProvider(): Generator - + @@ -121,7 +121,7 @@ public function dataFormatterOutputProvider(): Generator - + ', diff --git a/tests/PHPStan/Command/ErrorFormatter/RawErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/RawErrorFormatterTest.php index 5b61402bbd..58b9e59bc9 100644 --- a/tests/PHPStan/Command/ErrorFormatter/RawErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/RawErrorFormatterTest.php @@ -41,7 +41,7 @@ public function dataFormatterOutputProvider(): iterable 0, '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:2:Bar' . "\nBar2\n" . '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:4:Foo' . "\n" . - '/data/folder/with space/and unicode 😃/project/foo.php:1:Foo' . "\n" . + '/data/folder/with space/and unicode 😃/project/foo.php:1:Foo' . "\n" . '/data/folder/with space/and unicode 😃/project/foo.php:5:Bar' . "\nBar2\n", ]; @@ -51,7 +51,7 @@ public function dataFormatterOutputProvider(): iterable 0, 2, '?:?:first generic error' . "\n" . - '?:?:second generic error' . "\n", + '?:?:second generic' . "\n", ]; yield [ @@ -60,10 +60,10 @@ public function dataFormatterOutputProvider(): iterable 4, 2, '?:?:first generic error' . "\n" . - '?:?:second generic error' . "\n" . + '?:?:second generic' . "\n" . '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:2:Bar' . "\nBar2\n" . '/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:4:Foo' . "\n" . - '/data/folder/with space/and unicode 😃/project/foo.php:1:Foo' . "\n" . + '/data/folder/with space/and unicode 😃/project/foo.php:1:Foo' . "\n" . '/data/folder/with space/and unicode 😃/project/foo.php:5:Bar' . "\nBar2\n", ]; } diff --git a/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php index 64facd9af9..374d810d45 100644 --- a/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php @@ -94,7 +94,7 @@ public function dataFormatterOutputProvider(): iterable ------ ---------- Line foo.php ------ ---------- - 1 Foo + 1 Foo 5 Bar Bar2 💡 a tip @@ -115,7 +115,7 @@ public function dataFormatterOutputProvider(): iterable Error -- ---------------------- first generic error - second generic error + second generic -- ---------------------- @@ -141,7 +141,7 @@ public function dataFormatterOutputProvider(): iterable ------ ---------- Line foo.php ------ ---------- - 1 Foo + 1 Foo 5 Bar Bar2 💡 a tip @@ -151,7 +151,7 @@ public function dataFormatterOutputProvider(): iterable Error -- ---------------------- first generic error - second generic error + second generic -- ---------------------- [ERROR] Found 6 errors diff --git a/tests/PHPStan/Command/ErrorFormatter/TeamcityErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/TeamcityErrorFormatterTest.php index c0932ac1d1..9e91634634 100644 --- a/tests/PHPStan/Command/ErrorFormatter/TeamcityErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/TeamcityErrorFormatterTest.php @@ -48,7 +48,7 @@ public function dataFormatterOutputProvider(): iterable '##teamcity[inspectionType id=\'phpstan\' name=\'phpstan\' category=\'phpstan\' description=\'phpstan Inspection\'] ##teamcity[inspection typeId=\'phpstan\' message=\'Bar||nBar2\' file=\'folder with unicode 😃/file name with "spaces" and unicode 😃.php\' line=\'2\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\'] ##teamcity[inspection typeId=\'phpstan\' message=\'Foo\' file=\'folder with unicode 😃/file name with "spaces" and unicode 😃.php\' line=\'4\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\'] -##teamcity[inspection typeId=\'phpstan\' message=\'Foo\' file=\'foo.php\' line=\'1\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\'] +##teamcity[inspection typeId=\'phpstan\' message=\'Foo\' file=\'foo.php\' line=\'1\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\'] ##teamcity[inspection typeId=\'phpstan\' message=\'Bar||nBar2\' file=\'foo.php\' line=\'5\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'a tip\'] ', ]; @@ -60,7 +60,7 @@ public function dataFormatterOutputProvider(): iterable 2, '##teamcity[inspectionType id=\'phpstan\' name=\'phpstan\' category=\'phpstan\' description=\'phpstan Inspection\'] ##teamcity[inspection typeId=\'phpstan\' message=\'first generic error\' file=\'.\' SEVERITY=\'ERROR\'] -##teamcity[inspection typeId=\'phpstan\' message=\'second generic error\' file=\'.\' SEVERITY=\'ERROR\'] +##teamcity[inspection typeId=\'phpstan\' message=\'second generic\' file=\'.\' SEVERITY=\'ERROR\'] ', ]; @@ -72,10 +72,10 @@ public function dataFormatterOutputProvider(): iterable '##teamcity[inspectionType id=\'phpstan\' name=\'phpstan\' category=\'phpstan\' description=\'phpstan Inspection\'] ##teamcity[inspection typeId=\'phpstan\' message=\'Bar||nBar2\' file=\'folder with unicode 😃/file name with "spaces" and unicode 😃.php\' line=\'2\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\'] ##teamcity[inspection typeId=\'phpstan\' message=\'Foo\' file=\'folder with unicode 😃/file name with "spaces" and unicode 😃.php\' line=\'4\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\'] -##teamcity[inspection typeId=\'phpstan\' message=\'Foo\' file=\'foo.php\' line=\'1\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\'] +##teamcity[inspection typeId=\'phpstan\' message=\'Foo\' file=\'foo.php\' line=\'1\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'\'] ##teamcity[inspection typeId=\'phpstan\' message=\'Bar||nBar2\' file=\'foo.php\' line=\'5\' SEVERITY=\'ERROR\' ignorable=\'1\' tip=\'a tip\'] ##teamcity[inspection typeId=\'phpstan\' message=\'first generic error\' file=\'.\' SEVERITY=\'ERROR\'] -##teamcity[inspection typeId=\'phpstan\' message=\'second generic error\' file=\'.\' SEVERITY=\'ERROR\'] +##teamcity[inspection typeId=\'phpstan\' message=\'second generic\' file=\'.\' SEVERITY=\'ERROR\'] ', ]; }