Skip to content

Commit 4dbbdbb

Browse files
committed
Tests: minor tweaks
The tests for PHPCS 4.x already run on PHPUnit 8.x and 9.x, these are just some small tweaks/simplifications which were not made before, but have now been made in the 3.x branch when enabling the test suite to run on PHPUnit 8.x and 9.x.
1 parent 4e7a847 commit 4dbbdbb

File tree

6 files changed

+18
-21
lines changed

6 files changed

+18
-21
lines changed

.github/CONTRIBUTING.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ Note: There may be an issue or PR open already. If so, please join the discussio
137137

138138
1. Fork/clone the repository.
139139
2. Run `composer install`.
140-
When installing on PHP >= 8.0, use `composer install --ignore-platform-req=php+`.
141140
3. Create a new branch off the `master` branch to hold your patch.
142141
If there is an open issue associated with your patch, including the issue number in the branch name is good practice.
143142

@@ -152,10 +151,8 @@ To help you with this, a number of convenience scripts are available:
152151
* `composer check-all` will run the `cs` + `test` checks in one go.
153152
* `composer cs` will check for code style violations.
154153
* `composer cbf` will run the autofixers for code style violations.
155-
* `composer test` will run the unit tests (only works when on PHP < 8.1).
156-
* `composer test-php8` will run the unit tests when you are working on PHP 8.1+.
157-
Please note that using a `phpunit.xml` overload config file will not work with this script!
158-
* `composer coverage` will run the unit tests with code coverage (only works when on PHP < 8.1).
154+
* `composer test` will run the unit tests.
155+
* `composer coverage` will run the unit tests with code coverage.
159156
Note: you may want to use a custom `phpunit.xml` overload config file to tell PHPUnit where to place an HTML report.
160157
Alternative run it like so: `composer coverage -- --coverage-html /path/to/report-dir/` to specify the location for the HTML report on the command line.
161158
* `composer build` will build the phpcs.phar and phpcbf.phar files.

.github/workflows/test.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,12 @@ jobs:
114114

115115
# Install dependencies and handle caching in one go.
116116
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
117-
- name: Install Composer dependencies - normal
118-
if: ${{ matrix.php != '8.1' }}
117+
- name: Install Composer dependencies
119118
uses: "ramsey/composer-install@v2"
120119
with:
121120
# Bust the cache at least once a month - output format: YYYY-MM.
122121
custom-cache-suffix: $(date -u "+%Y-%m")
123122

124-
# For PHP > 8.0, install with ignore platform reqs as not all PHPUnit allow for it yet.
125-
- name: Install Composer dependencies - with ignore platform
126-
if: ${{ matrix.php == '8.1' || matrix.php == '8.2' }}
127-
uses: "ramsey/composer-install@v2"
128-
with:
129-
composer-options: --ignore-platform-req=php+
130-
custom-cache-suffix: $(date -u "+%Y-%m")
131-
132123
# Note: The code style check is run multiple times against every PHP version
133124
# as it also acts as an integration test.
134125
- name: 'PHPCS: set the path to PHP'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/CodeSniffer.conf
22
/phpcs.xml
33
/phpunit.xml
4+
.phpunit.result.cache
45
.idea/*
56
/vendor/
67
composer.lock

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ The file documents changes to the PHP_CodeSniffer project.
138138
- PSR2.Methods.FunctionCallSignature
139139
- PSR2.Methods.FunctionClosingBrace
140140
- Thanks to Atsushi Okui (@blue32a) for the patch
141+
- Support for PHPUnit 8 and 9 to the test suite.
142+
- Test suites for external standards which run via the PHPCS native test suite can now run on PHPUnit 4-9 (was 4-7).
143+
- If any of these tests use the PHPUnit `setUp()`/`tearDown()` methods or overload the `setUp()` in the `AbstractSniffUnitTest` test case, they will need to be adjusted. See the [PR details for further information](https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/59/commits/26384ebfcc0b1c1651b0e1e40c9b6c8c22881832).
141144

142145
### Changed
143146
- Changes have been made to the way PHPCS handles invalid sniff properties being set in a custom ruleset

composer.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@
6060
"Composer\\Config::disableProcessTimeout",
6161
"@php ./vendor/phpunit/phpunit/phpunit tests/AllTests.php --no-coverage"
6262
],
63-
"test-php8": [
64-
"Composer\\Config::disableProcessTimeout",
65-
"@php ./vendor/phpunit/phpunit/phpunit tests/AllTests.php --no-configuration --bootstrap=tests/bootstrap.php --dont-report-useless-tests --no-coverage"
66-
],
6763
"coverage": [
6864
"Composer\\Config::disableProcessTimeout",
6965
"@php ./vendor/phpunit/phpunit/phpunit tests/AllTests.php -d max_execution_time=0"
@@ -81,7 +77,6 @@
8177
"cs": "Check for code style violations.",
8278
"cbf": "Fix code style violations.",
8379
"test": "Run the unit tests without code coverage.",
84-
"test-php8": "Run the unit tests without code coverage on PHP 8.1 or higher.",
8580
"coverage": "Run the unit tests with code coverage.",
8681
"build": "Create PHAR files for PHPCS and PHPCBF.",
8782
"check-all": "Run all checks (phpcs, tests)."

phpunit.xml.dist

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="true" beStrictAboutTestsThatDoNotTestAnything="false" convertDeprecationsToExceptions="true" bootstrap="tests/bootstrap.php">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.2/phpunit.xsd"
5+
backupGlobals="true"
6+
beStrictAboutTestsThatDoNotTestAnything="false"
7+
bootstrap="tests/bootstrap.php"
8+
convertErrorsToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
convertNoticesToExceptions="true"
11+
convertDeprecationsToExceptions="true"
12+
>
313
<testsuites>
414
<testsuite name="PHP_CodeSniffer Test Suite">
515
<file>tests/AllTests.php</file>

0 commit comments

Comments
 (0)