Repository navigation
Add a unit test for the "ValidBlockLibraryFunctionNameSniff" sniff - #53928
Merged
Merged
Conversation
anton-vlasenko
force-pushed
the
fix/gutenberg-coding-standards-unit-tests
branch
from
August 24, 2023 21:01
58e0aca to
22e1b27
Compare
ValidBlockLibraryFunctionNameSniff sniff
ValidBlockLibraryFunctionNameSniff sniff
anton-vlasenko
requested review from
azaozz,
gziolo,
hellofromtonya,
ironprogrammer,
ockham and
tellthemachines
August 24, 2023 21:12
anton-vlasenko
marked this pull request as ready for review
August 24, 2023 21:13
Member
|
Thanks for this PR, @anton-vlasenko! Test ReportActual Results
Additional Scenarios
Supplemental Artifacts |
anton-vlasenko
force-pushed
the
fix/gutenberg-coding-standards-unit-tests
branch
from
September 19, 2023 10:29
fc779b9 to
7c2ab3c
Compare
|
Flaky tests detected in 714e8a6. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6312515538
|
anton-vlasenko
force-pushed
the
fix/gutenberg-coding-standards-unit-tests
branch
from
September 25, 2023 17:06
c654129 to
1c0c248
Compare
anton-vlasenko
force-pushed
the
fix/gutenberg-coding-standards-unit-tests
branch
2 times, most recently
from
September 25, 2023 18:24
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).
anton-vlasenko
force-pushed
the
fix/gutenberg-coding-standards-unit-tests
branch
from
September 26, 2023 12:19
dc5936f to
714e8a6
Compare
ironprogrammer
approved these changes
Sep 26, 2023
ironprogrammer
left a comment
Member
There was a problem hiding this comment.
I re-ran tests after the recent syncs with trunk and it looks good, @anton-vlasenko -- I approve this PR.
Contributor
Author
|
Thank you, @ironprogrammer ! |
anton-vlasenko
deleted the
fix/gutenberg-coding-standards-unit-tests
branch
September 27, 2023 10:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
This PR aims to add a unit test for the recently introduced
ValidBlockLibraryFunctionNameSniffsniff.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?
ValidBlockLibraryFunctionNameSniffsniff.phpcs.xml.distby 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-installerfrom 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_codesnifferpackage 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.