Tests: Add unit test coverage for Amend_Check_Result trait - #1485
noruzzamans wants to merge 3 commits into
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. |
|
Thanks for your contribution. The test setup creates a symlink in WP_PLUGIN_DIR, but tear_down() never removes it. This leaves global fixture state behind for the remainder of the suite — and potentially in the wp-env volume — which can affect later tests that enumerate plugins or use the same path. Please clean it up in tear_down(), ideally tracking whether this test class created the symlink so it does not remove one owned by another test. |
|
Thanks for catching this, @davidperezgar! That's a great point regarding global fixture state leakage and preserving symlinks owned by other tests or prior suite runs. I have updated the test class in commit
Local PHPCS ( |
Description
This pull request introduces a comprehensive unit test suite for the
WordPress\Plugin_Check\Traits\Amend_Check_Resulttrait (includes/Traits/Amend_Check_Result.php).Amend_Check_Resultis a core architectural trait composed by over 25 check classes acrossWordPress/plugin-check(includingPlugin_Content_Check,Direct_File_Access_Check,File_Type_Check,Trademarks_Check,Setting_Sanitization_Check,Write_File_Check,Safe_Redirect_Check, andNo_Unfiltered_Uploads_Check) to format and record issue notices intoCheck_Result.While companion traits such as
File_Editor_URL,Readme_Utils,Language_Utils,License_Utils,Version_Utils, andAmend_DB_Base_Prefixpossess dedicated unit tests undertests/phpunit/tests/Traits/,Amend_Check_Resultpreviously lacked dedicated unit test coverage.Test Coverage Highlights
The new test suite in
tests/phpunit/tests/Traits/Amend_Check_Result_Tests.phpvalidates:add_result_error_for_file): Confirms that errors are added to the result stack, error count increments, and warning stack remains unaffected.add_result_warning_for_file): Confirms that warnings are added to the result stack, warning count increments, and error stack remains unaffected.add_result_message_for_file): Verifies proper casting of truthy and falsy values to error versus warning stacks.0), column (0), docs (''), and severity (5).File_Editor_URLandwp_plugin_check_validation_error_source_urlfilter to populate'link'in message metadata.nullwhen the user lacks edit capabilities and no custom filter is set.Quality & Standards
composer lint(PHPCS VIPWPCS / WordPress-Core).composer phpstan(PHPStan Level 8, 0 errors).