Skip to content

Commit

Permalink
Make check for requires headers an error
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Feb 3, 2025
1 parent d528d19 commit 90a6da0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ private function check_requires_headers( Check_Result $result, string $readme_fi
$plugin_value = $plugin_data[ $requires[ $require ]['header_field'] ];

if ( $readme_value !== $plugin_value ) {
$this->add_result_warning_for_file(
$this->add_result_error_for_file(
$result,
sprintf(
/* translators: 1: readme header tag, 2: versions comparison */
Expand All @@ -847,8 +847,7 @@ private function check_requires_headers( Check_Result $result, string $readme_fi
$readme_file,
0,
0,
'https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/#readme-header-information',
6
'https://developer.wordpress.org/plugins/wordpress-org/how-your-readme-txt-works/#readme-header-information'
);
}
}
Expand Down
10 changes: 5 additions & 5 deletions tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,12 @@ public function test_run_with_mismatched_requires_headers() {

$check->run( $check_result );

$warnings = $check_result->get_warnings();
$errors = $check_result->get_errors();

$this->assertNotEmpty( $warnings );
$this->assertArrayHasKey( 'readme.txt', $warnings );
$this->assertNotEmpty( $errors );
$this->assertArrayHasKey( 'readme.txt', $errors );

$this->assertCount( 1, wp_list_filter( $warnings['readme.txt'][0][0], array( 'code' => 'readme_mismatched_header_requires' ) ) );
$this->assertCount( 1, wp_list_filter( $warnings['readme.txt'][0][0], array( 'code' => 'readme_mismatched_header_requires_php' ) ) );
$this->assertCount( 1, wp_list_filter( $errors['readme.txt'][0][0], array( 'code' => 'readme_mismatched_header_requires' ) ) );
$this->assertCount( 1, wp_list_filter( $errors['readme.txt'][0][0], array( 'code' => 'readme_mismatched_header_requires_php' ) ) );
}
}

0 comments on commit 90a6da0

Please sign in to comment.