diff --git a/.gitattributes b/.gitattributes index 99fda76..c3ed26d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,4 +4,5 @@ .gitignore export-ignore /.github export-ignore phpunit.xml.dist export-ignore +phpunit10.xml.dist export-ignore phpcs.xml.dist export-ignore diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0fa2d1a..d648ee1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -73,9 +73,18 @@ jobs: - name: Lint run: composer phplint -- --checkstyle | cs2pr - - 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 phpunit + - name: "Run unit tests (PHPUnit 10+)" + if: ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }} + run: composer phpunit10 + coverage: needs: test # Don't run on forks. @@ -124,9 +133,18 @@ jobs: - name: Lint run: composer phplint -- --checkstyle | cs2pr - - name: Run the unit tests with code coverage + - 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 the unit tests with code coverage (PHPUnit < 10)" + if: ${{ ! startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }} run: composer coverage + - name: "Run the unit tests with code coverage (PHPUnit 10+)" + if: ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }} + run: composer coverage10 + - name: Upload coverage results to Coveralls if: ${{ success() }} uses: coverallsapp/github-action@v2 diff --git a/.gitignore b/.gitignore index 468ad40..de58d45 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /vendor/ /composer.lock phpunit.xml +phpunit10.xml .phpunit.result.cache .phpcs.xml phpcs.xml diff --git a/composer.json b/composer.json index 3e77214..85b11fa 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "php-parallel-lint/php-console-color": "^1.0.1" }, "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-parallel-lint": "^1.0", "php-parallel-lint/php-var-dump-check": "0.*", "php-parallel-lint/php-code-style": "^2.0" @@ -55,9 +55,15 @@ "phpunit": [ "@php ./vendor/phpunit/phpunit/phpunit --no-coverage" ], + "phpunit10": [ + "@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" + ], "build": [ "@phplint", "@vardumpcheck", @@ -70,8 +76,10 @@ "vardumpcheck": "Check PHP files for forgotten variable dumps", "phpcs": "Check PHP code style", "fixcs": "Auto-fix PHP code style", - "phpunit": "PHP unit", - "coverage": "PHP unit with code coverage", + "phpunit": "Run the unit tests on PHPUnit 4.x - 9.x without code coverage.", + "phpunit10": "Run the unit tests on PHPUnit 10.x without code coverage.", + "coverage": "Run the unit tests on PHPUnit 4.x - 9.x with code coverage.", + "coverage10": "Run the unit tests on PHPUnit 10.x with code coverage.", "build": "Run all checks" } } diff --git a/phpunit10.xml.dist b/phpunit10.xml.dist new file mode 100644 index 0000000..065f3e1 --- /dev/null +++ b/phpunit10.xml.dist @@ -0,0 +1,44 @@ + + + + + + tests + + + + + + ./src/ + + + + + + + + + + + + + + +