PHPCS: Exclude PHPUnit tests from file and class name sniffs (for Core parity) #43131
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Use Core's file and class name sniffs exclusions for the PHPUnit tests.
Why?
To reduce the effort of backporting tests to Core by increasing parity to WordPress Coding Standards.
Test Classes and files in Core require the following:
So a test file is named as:
group/funcName.php
orgroup/className.php
.Core's tests include the same exclusions in its
phpcs.xml.dist
file.How?
Testing Instructions
Before applying the patch:
class-wp-webfonts-test.php
file towpWebfonts.php
.WP_Webfonts_Test
toTests_Webfonts_WpWebfonts
.npm run lint:php phpunit/wpWebfonts.php
.Results:
WordPress.Files.FileName.NotHyphenatedLowercase
linting error.After applying the patch:
Rerun step 3 above. Results: No linting errors.