Tests: Add unit test suite for Ignore_Matcher utility - #1479
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Looks good to me. The new tests provide focused coverage for Ignore_Matcher’s anchored/unanchored matching, wildcard behavior, negative cases, and PHPCS pattern generation. All CI checks are passing. Nice addition—thanks! |
Thanks for the review and kind words, @davidperezgar! Glad to contribute. |
Description
This pull request introduces a dedicated, comprehensive PHPUnit test suite for the
WordPress\Plugin_Check\Utilities\Ignore_Matcherclass introduced in version 2.2.0 as part of the.pcpignoreexclusion engine.While
Plugin_Request_Utility_Testscontains high-level integration checks,Ignore_Matchercontains core path normalization, glob-to-regex conversion, and wildcard matching algorithms that previously lacked direct, isolated unit test coverage.Scope of Coverage (
Ignore_Matcher_Tests.php)The new test suite (
tests/phpunit/tests/Utilities/Ignore_Matcher_Tests.php) covers all 5 methods and edge cases across 21 test cases:split_anchored_entries:/docs,/build/*.map,/src/file?.js) from unanchored entries (vendor,*.log,node_modules).is_file_in_ignored_directory:/vendor/autoload.php,/assets/vendor/lib.js).my-vendorandvendorsnot matchingvendor)./sub/docs/not matching/docs).*(e.g./build*matching/build-v1/and/build-prod/).?(e.g./temp-?matching/temp-1/and/temp-a/, but rejecting/temp-12/).is_file_ignored:app.min.js).my-app.min.jsandapp.min.js.mapnot matchingapp.min.js)./package.json)./assets/package.jsonnot matching/package.json).*(/*.mapmatching root maps without crossing directory boundaries).?(/data-?.jsonmatching single-character variants and rejecting/data-10.json).get_php_codesniffer_directory_ignore_pattern:^anchor and/*suffix.*to[^/]{0,},?to[^/]).-,[,],.).get_php_codesniffer_file_ignore_pattern:^anchor and$suffix./*.map,/file?.php).Quality Gates Passed Locally
php -l tests/phpunit/tests/Utilities/Ignore_Matcher_Tests.php(Passed with 0 errors)composer lint/./vendor/bin/phpcs(202/202 files, 100% clean, 0 errors, 0 warnings)composer phpstan(114/114 files, 100% clean, Level 5, 0 errors)