Skip to content

Commit

Permalink
Merge pull request #839 from WordPress/improve-missing-readme-header
Browse files Browse the repository at this point in the history
Unique error code for each missing readme headers
  • Loading branch information
davidperezgar authored Dec 20, 2024
2 parents 9990e92 + 6e59230 commit e7d1d80
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 3 additions & 3 deletions includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ private function check_headers( Check_Result $result, string $readme_file, Parse
$result,
sprintf(
/* translators: %s: readme header field */
__( '<strong>Missing "%s".</strong><br>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'
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down

0 comments on commit e7d1d80

Please sign in to comment.