diff --git a/.gitattributes b/.gitattributes index 2eb1a64..a0a6f39 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,15 +5,16 @@ # https://www.reddit.com/r/PHP/comments/2jzp6k/i_dont_need_your_tests_in_my_production # https://blog.madewithlove.be/post/gitattributes/ # -.gitattributes export-ignore -.gitignore export-ignore -appveyor.yml export-ignore -box.json export-ignore -phpcs.xml.dist export-ignore -phpunit.xml.dist export-ignore -/.github/ export-ignore -/doc/ export-ignore -/tests/ export-ignore +.gitattributes export-ignore +.gitignore export-ignore +appveyor.yml export-ignore +box.json export-ignore +phpcs.xml.dist export-ignore +phpunit.xml.dist export-ignore +phpunit10.xml.dist export-ignore +/.github/ export-ignore +/doc/ export-ignore +/tests/ export-ignore # # Auto detect text files and perform LF normalization diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5157fba..24a750b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -152,9 +152,18 @@ jobs: - name: 'Integration test 2 - linting own code' run: ./parallel-lint --exclude vendor --exclude tests/fixtures . - - name: 'Run unit tests' + - name: Grab PHPUnit version + id: phpunit_version + run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT + + - name: "Run unit tests (PHPUnit < 10)" + if: ${{ ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }} run: composer test + - name: "Run unit tests (PHPUnit < 10)" + if: ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }} + run: composer test10 + - uses: actions/download-artifact@v4 with: name: parallel-lint-phar diff --git a/.gitignore b/.gitignore index 4c1c0ec..5938b53 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ composer.lock phpcs.xml .phpunit.result.cache phpunit.xml +phpunit10.xml diff --git a/composer.json b/composer.json index 2e3caac..334e2eb 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "jakub-onderka/php-parallel-lint": "*" }, "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0", + "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.1", "php-parallel-lint/php-console-highlighter": "0.* || ^1.0", "php-parallel-lint/php-code-style": "^2.0" }, @@ -50,10 +50,14 @@ ], "scripts": { "test": "@php ./vendor/phpunit/phpunit/phpunit --no-coverage", - "coverage": "@php ./vendor/phpunit/phpunit/phpunit" + "test10": "@php ./vendor/phpunit/phpunit/phpunit -c phpunit10.xml.dist --no-coverage", + "coverage": "@php ./vendor/phpunit/phpunit/phpunit", + "coverage10": "@php ./vendor/phpunit/phpunit/phpunit -c phpunit10.xml.dist" }, "scripts-descriptions": { - "test": "Run all tests!", - "coverage": "Run all tests *with code coverage*" + "test": "Run all tests! ( PHPUnit < 10)", + "test10": "Run all tests! ( PHPUnit 10+)", + "coverage": "Run all tests *with code coverage* ( PHPUnit < 10)", + "coverage10": "Run all tests *with code coverage* ( PHPUnit 10+)" } } diff --git a/phpunit10.xml.dist b/phpunit10.xml.dist new file mode 100644 index 0000000..140810b --- /dev/null +++ b/phpunit10.xml.dist @@ -0,0 +1,40 @@ + + + + + + tests/Unit + + + + + + ./src/ + + + + + + + + + + + diff --git a/tests/Unit/Errors/ParallelLintErrorTest.php b/tests/Unit/Errors/ParallelLintErrorTest.php index 8bda3cc..db69b55 100644 --- a/tests/Unit/Errors/ParallelLintErrorTest.php +++ b/tests/Unit/Errors/ParallelLintErrorTest.php @@ -31,7 +31,7 @@ public function testGetMessage($message, $expected) * * @return array */ - public function dataGetMessage() + public static function dataGetMessage() { return array( 'Message: empty string' => array( @@ -88,7 +88,7 @@ public function testGetShortFilePath($filePath, $expectedShort) * * @return array */ - public function dataGetFilePath() + public static function dataGetFilePath() { $cwd = getcwd(); diff --git a/tests/Unit/Errors/SyntaxErrorGetLineTest.php b/tests/Unit/Errors/SyntaxErrorGetLineTest.php index 86b824c..dd10e71 100644 --- a/tests/Unit/Errors/SyntaxErrorGetLineTest.php +++ b/tests/Unit/Errors/SyntaxErrorGetLineTest.php @@ -31,7 +31,7 @@ public function testGetLine($message, $expected) * * @return array */ - public function dataGetLine() + public static function dataGetLine() { return array( 'Message: empty string' => array( diff --git a/tests/Unit/Errors/SyntaxErrorGetNormalizeMessageTest.php b/tests/Unit/Errors/SyntaxErrorGetNormalizeMessageTest.php index 8eb47aa..7223cc4 100644 --- a/tests/Unit/Errors/SyntaxErrorGetNormalizeMessageTest.php +++ b/tests/Unit/Errors/SyntaxErrorGetNormalizeMessageTest.php @@ -31,7 +31,7 @@ public function testMessageNormalizationWithoutTokenTranslation($message, $expec * * @return array */ - public function dataMessageNormalization() + public static function dataMessageNormalization() { return array( 'Strip leading and trailing information - fatal error' => array( @@ -85,7 +85,7 @@ public function testFilePathHandling($filePath, $fileName) * * @return array */ - public function dataFilePathHandling() + public static function dataFilePathHandling() { return array( 'Plain file name' => array( diff --git a/tests/Unit/Errors/SyntaxErrorTranslateTokensTest.php b/tests/Unit/Errors/SyntaxErrorTranslateTokensTest.php index a991c63..a1b5c44 100644 --- a/tests/Unit/Errors/SyntaxErrorTranslateTokensTest.php +++ b/tests/Unit/Errors/SyntaxErrorTranslateTokensTest.php @@ -31,7 +31,7 @@ public function testTranslateTokens($message, $expected) * * @return array */ - public function dataTranslateTokens() + public static function dataTranslateTokens() { return array( 'No token name in message' => array( diff --git a/tests/Unit/Outputs/OutputTest.php b/tests/Unit/Outputs/OutputTest.php index 79b5b8e..8deed33 100644 --- a/tests/Unit/Outputs/OutputTest.php +++ b/tests/Unit/Outputs/OutputTest.php @@ -68,7 +68,7 @@ public function testCheckstyleOutput() $this->assertInstanceOf('SimpleXMLElement', $parsed); } - public function getGitLabOutputData() + public static function getGitLabOutputData() { return array( array( diff --git a/tests/Unit/SettingsAddPathsTest.php b/tests/Unit/SettingsAddPathsTest.php index 182e3f1..bd72c0d 100644 --- a/tests/Unit/SettingsAddPathsTest.php +++ b/tests/Unit/SettingsAddPathsTest.php @@ -36,7 +36,7 @@ public function testAddPaths($original, $extra, $expected) * * @return array */ - public function dataAddPaths() + public static function dataAddPaths() { return array( 'No paths passed on CLI, no extra paths' => array( diff --git a/tests/Unit/SettingsParseArgumentsTest.php b/tests/Unit/SettingsParseArgumentsTest.php index 6bd751d..55e5102 100644 --- a/tests/Unit/SettingsParseArgumentsTest.php +++ b/tests/Unit/SettingsParseArgumentsTest.php @@ -35,7 +35,7 @@ public function testParseArgumentsInvalidArgument($command, $unsupported) * * @return array */ - public function dataParseArgumentsInvalidArgument() + public static function dataParseArgumentsInvalidArgument() { return array( 'Unsupported short argument' => array( @@ -79,7 +79,7 @@ public function testParseArguments($command, array $expectedChanged) * * @return array */ - public function dataParseArguments() + public static function dataParseArguments() { return array( 'No arguments at all' => array(