-
Notifications
You must be signed in to change notification settings - Fork 83
Check Mismatched Tested up to #1135
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
base: trunk
Are you sure you want to change the base?
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. |
|
|
||
| // Get the "Tested up to" value from the plugin header. | ||
| $plugin_header = get_file_data( | ||
| $plugin_main_file, |
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.
We already have helper for this "private function get_plugin_data()"
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.
Moreover this check should be in 'Plugin_Header_Fields_Check.php" class.
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.
It's easier in Readme as the readme parser is already loaded. My first approach was to load in the Header fields and you need more functions to load.
|
|
||
| // The "Tested up to" mismatch check has been moved to Plugin_Readme_Check. | ||
| // This test now verifies that Plugin_Header_Fields_Check does NOT report this error. | ||
| if ( isset( $errors['load.php'][0][0] ) ) { |
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.
We should try to avoid such "if" conditionals in the unit tests.
| // Note: Other readme errors may still be present. | ||
| if ( ! empty( $errors ) ) { | ||
| foreach ( $errors as $file => $file_errors ) { | ||
| if ( isset( $file_errors[0][0] ) ) { |
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.
"wp_list_filter" approach is better to fetch code here I guess.
| @@ -0,0 +1,145 @@ | |||
| <?php | |||
| /** | |||
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.
Instead of creating separate file for this "Tested_Up_To_Check_Tests.php", we could include it in "Plugin_Header_Fields_Check_Tests.php" to simplify.
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.
The check is in readme checks.
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.
It's part of Readme checks, not Plugin Header.
Fixes #1134
This check validates that the "Tested up to" header matches between the plugin's main file header and the readme.txt file.
Problem
The "Tested up to" header can exist in both:
When both are present, they must be exactly the same. If they differ, it can lead to:
Solution
The check has been integrated into the
Plugin_Header_Fields_Checkclass and performs the following validation:Find_Readmetrait into a more genericReadme_Utilstrait and moved theget_readme_tested_value()method fromPlugin_Header_Fields_Checkinto it for better code reusability.Implementation Details
Location
includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.phpcheck_tested_up_to_mismatch()tests/phpunit/tests/Checker/Checks/Tested_Up_To_Check_Tests.phptests/phpunit/tests/Checker/Checks/Plugin_Header_Fields_Check_Tests.phpError Code
mismatched_tested_up_to_headerSeverity
Test Coverage
The following test cases are included:
test_run_with_mismatch()- Verifies error is reported when values don't matchtest_run_with_match()- Verifies no error when values matchtest_run_with_readme_only()- Verifies no error when only readme has the valuetest_run_with_header_only()- Verifies no error when only header has the valuetest_run_with_single_file_plugin()- Verifies single-file plugins are skippedtest_run_with_no_readme()- Verifies no error when readme doesn't existPlugin_Header_Fields_Check_Tests.phpfor integration testingUsage
The check runs automatically as part of the
Plugin_Header_Fields_Checkand will report errors when:Error Message
When a mismatch is detected, the following error is displayed:
Documentation URL
https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/#readme-header-information