From 03475a8586a3ad0337fe5574344524e2dc4d57ef Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Thu, 19 Dec 2024 12:58:44 +0545 Subject: [PATCH 1/2] Improve missing readme header --- includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php index ae5c8aac..04d0851d 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php @@ -248,14 +248,14 @@ private function check_headers( Check_Result $result, string $readme_file, Parse $result, sprintf( /* translators: %s: readme header field */ - __( 'Missing "%s".
Your readme has to have headers as well as a proper description and documentation as to how it works and how one can use it.', 'plugin-check' ), + __( 'The "%s" header is missing in the readme file.', 'plugin-check' ), $field['label'] ), - 'missing_readme_header', + 'missing_readme_header_' . $field_key, $readme_file, 0, 0, - 'https://developer.wordpress.org/plugins/wordpress-org/common-issues/#incomplete-readme' + 'https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/#readme-header-information' ); } } From 6e592308e0cf5c437580fea0948798bc9f570670 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Thu, 19 Dec 2024 14:48:15 +0545 Subject: [PATCH 2/2] Add unit test for missing readme header --- .../readme.txt | 1 - .../Checker/Checks/Plugin_Readme_Check_Tests.php | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/testdata/plugins/test-plugin-plugin-readme-errors-upgrade-notice/readme.txt b/tests/phpunit/testdata/plugins/test-plugin-plugin-readme-errors-upgrade-notice/readme.txt index c9de95a1..809d9ab4 100644 --- a/tests/phpunit/testdata/plugins/test-plugin-plugin-readme-errors-upgrade-notice/readme.txt +++ b/tests/phpunit/testdata/plugins/test-plugin-plugin-readme-errors-upgrade-notice/readme.txt @@ -2,7 +2,6 @@ Contributors: plugin-check Requires at least: 6.0 -Tested up to: 6.1 Requires PHP: 5.6 Stable tag: 1.0.0 License: GPLv2 or later diff --git a/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php index 4e6944e7..6c023e61 100644 --- a/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php @@ -232,6 +232,22 @@ public function test_run_with_errors_tested_upto() { $this->assertCount( 1, wp_list_filter( $errors['readme.txt'][0][0], array( 'code' => 'outdated_tested_upto_header' ) ) ); } + public function test_run_with_errors_missing_readme_headers() { + $readme_check = new Plugin_Readme_Check(); + $check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-errors-upgrade-notice/load.php' ); + $check_result = new Check_Result( $check_context ); + + $readme_check->run( $check_result ); + + $errors = $check_result->get_errors(); + + $this->assertNotEmpty( $errors ); + $this->assertArrayHasKey( 'readme.txt', $errors ); + + // Check for missing tested upto header. + $this->assertCount( 1, wp_list_filter( $errors['readme.txt'][0][0], array( 'code' => 'missing_readme_header_tested' ) ) ); + } + public function test_run_md_with_errors() { $readme_check = new Plugin_Readme_Check(); $check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-md-with-errors/load.php' );