-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a unit test for the "ValidBlockLibraryFunctionNameSniff" sniff #53928
Add a unit test for the "ValidBlockLibraryFunctionNameSniff" sniff #53928
Conversation
58e0aca
to
22e1b27
Compare
ValidBlockLibraryFunctionNameSniff
sniff
ValidBlockLibraryFunctionNameSniff
sniff
Thanks for this PR, @anton-vlasenko! Test ReportActual Results
Additional Scenarios
Supplemental Artifacts |
...g-coding-standards/Gutenberg/Sniffs/NamingConventions/ValidBlockLibraryFunctionNameSniff.php
Outdated
Show resolved
Hide resolved
fc779b9
to
7c2ab3c
Compare
Flaky tests detected in 714e8a6. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6312515538
|
c654129
to
1c0c248
Compare
40f5dd2
to
dc5936f
Compare
2. Bump the minimum required PHP version to 7.0. 3. Refine `phpcs.xml.dist` by only excluding necessary rules. 4. Update WPCS to 3.0. 5. Refactor `ValidBlockLibraryFunctionNameSniff::processFunctionToken()`: eliminate the need to loop through all available prefixes once the function name is confirmed as valid; this results in a minor performance improvement. 6. Remove `dealerdirect/phpcodesniffer-composer-installer` from the list of dependencies per WPCS 3.0 [upgrade guide](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-3.0.0-for-ruleset-maintainers).
dc5936f
to
714e8a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I re-ran tests after the recent syncs with trunk
and it looks good, @anton-vlasenko -- I approve this PR.
Thank you, @ironprogrammer ! |
What?
This PR aims to add a unit test for the recently introduced
ValidBlockLibraryFunctionNameSniff
sniff.It also brings a few other minor improvements.
Fixes #53731.
Why?
It's considered best practice to write unit tests for PHPCS sniffs.
Additionally, as Gutenberg moves toward bumping the minimum supported PHP version, this package should also be updated.
How?
ValidBlockLibraryFunctionNameSniff
sniff.phpcs.xml.dist
by only excluding necessary rules.ValidBlockLibraryFunctionNameSniff::processFunctionToken()
: eliminate the need to loop through all available prefixes once the function name is confirmed as valid; this results in a minor performance improvement.dealerdirect/phpcodesniffer-composer-installer
from the list of dependencies per WPCS 3.0 upgrade guide.Testing Instructions
test/php/gutenberg-coding-standards/
.composer update
.composer run check-all
.Ensure that the PHPUnit tests in the console pass. PHPUnit should report 0 assertions, but that is expected.
Note
: The unit tests will not work on PHP 8.0 and above. This is because the latest stable version of thesquizlabs/php_codesniffer
package doesn't support PHPUnit 8.x. Also, PHPUnit 7.x is not compatible with PHP 8.0. The unit tests have been confirmed to work on PHP 7.3.