Skip to content

Commit

Permalink
Update severity of certain checks in Plugin_Readme_Check
Browse files Browse the repository at this point in the history
  • Loading branch information
mukeshpanchal27 committed Sep 25, 2023
1 parent 42c2b20 commit 32b69c2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 31 deletions.
4 changes: 2 additions & 2 deletions includes/Checker/Checks/Plugin_Readme_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private function check_stable_tag( Check_Result $result, array $files ) {

if ( 'trunk' === $stable_tag ) {
$result->add_message(
false,
true,
__( "It's recommended not to use 'Stable Tag: trunk'.", 'plugin-check' ),
array(
'code' => 'trunk_stable_tag',
Expand All @@ -200,7 +200,7 @@ private function check_stable_tag( Check_Result $result, array $files ) {
$stable_tag !== $plugin_data['Version']
) {
$result->add_message(
false,
true,
__( 'The Stable Tag in your readme file does not match the version in your main plugin file.', 'plugin-check' ),
array(
'code' => 'stable_tag_mismatch',
Expand Down
63 changes: 34 additions & 29 deletions tests/phpunit/Checker/Checks/Plugin_Readme_Check_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ public function test_run_with_errors_stable_tag() {

$readme_check->run( $check_result );

$warnings = $check_result->get_warnings();

$this->assertNotEmpty( $warnings );
$this->assertArrayHasKey( 'readme.txt', $warnings );
$this->assertEquals( 2, $check_result->get_warning_count() );

// Check for trunk stable tag warning.
$this->assertArrayHasKey( 0, $warnings['readme.txt'] );
$this->assertArrayHasKey( 0, $warnings['readme.txt'][0] );
$this->assertArrayHasKey( 'code', $warnings['readme.txt'][0][0][0] );
$this->assertEquals( 'trunk_stable_tag', $warnings['readme.txt'][0][0][0]['code'] );

// Check for stable tag mismatch file warning.
$this->assertArrayHasKey( 0, $warnings['readme.txt'] );
$this->assertArrayHasKey( 0, $warnings['readme.txt'][0] );
$this->assertArrayHasKey( 'code', $warnings['readme.txt'][0][0][1] );
$this->assertEquals( 'stable_tag_mismatch', $warnings['readme.txt'][0][0][1]['code'] );
$errors = $check_result->get_errors();

$this->assertNotEmpty( $errors );
$this->assertArrayHasKey( 'readme.txt', $errors );
$this->assertEquals( 2, $check_result->get_error_count() );

// Check for trunk stable tag error.
$this->assertArrayHasKey( 0, $errors['readme.txt'] );
$this->assertArrayHasKey( 0, $errors['readme.txt'][0] );
$this->assertArrayHasKey( 'code', $errors['readme.txt'][0][0][0] );
$this->assertEquals( 'trunk_stable_tag', $errors['readme.txt'][0][0][0]['code'] );

// Check for stable tag mismatch file error.
$this->assertArrayHasKey( 0, $errors['readme.txt'] );
$this->assertArrayHasKey( 0, $errors['readme.txt'][0] );
$this->assertArrayHasKey( 'code', $errors['readme.txt'][0][0][1] );
$this->assertEquals( 'stable_tag_mismatch', $errors['readme.txt'][0][0][1]['code'] );
}

public function test_run_with_errors_license() {
Expand Down Expand Up @@ -136,11 +136,16 @@ public function test_run_md_with_errors() {

$readme_check->run( $check_result );

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

$this->assertNotEmpty( $errors );
$this->assertArrayHasKey( 'readme.md', $errors );
$this->assertEquals( 2, $check_result->get_error_count() );

$this->assertNotEmpty( $warnings );
$this->assertArrayHasKey( 'readme.md', $warnings );
$this->assertEquals( 4, $check_result->get_warning_count() );
$this->assertEquals( 2, $check_result->get_warning_count() );

// Check for default text file warning.
$this->assertArrayHasKey( 0, $warnings['readme.md'] );
Expand All @@ -154,17 +159,17 @@ public function test_run_md_with_errors() {
$this->assertArrayHasKey( 'code', $warnings['readme.md'][0][0][1] );
$this->assertEquals( 'invalid_license', $warnings['readme.md'][0][0][1]['code'] );

// Check for trunk stable tag warning.
$this->assertArrayHasKey( 0, $warnings['readme.md'] );
$this->assertArrayHasKey( 0, $warnings['readme.md'][0] );
$this->assertArrayHasKey( 'code', $warnings['readme.md'][0][0][2] );
$this->assertEquals( 'trunk_stable_tag', $warnings['readme.md'][0][0][2]['code'] );

// Check for stable tag mismatch file warning.
$this->assertArrayHasKey( 0, $warnings['readme.md'] );
$this->assertArrayHasKey( 0, $warnings['readme.md'][0] );
$this->assertArrayHasKey( 'code', $warnings['readme.md'][0][0][3] );
$this->assertEquals( 'stable_tag_mismatch', $warnings['readme.md'][0][0][3]['code'] );
// Check for trunk stable tag error.
$this->assertArrayHasKey( 0, $errors['readme.md'] );
$this->assertArrayHasKey( 0, $errors['readme.md'][0] );
$this->assertArrayHasKey( 'code', $errors['readme.md'][0][0][0] );
$this->assertEquals( 'trunk_stable_tag', $errors['readme.md'][0][0][0]['code'] );

// Check for stable tag mismatch file error.
$this->assertArrayHasKey( 0, $errors['readme.md'] );
$this->assertArrayHasKey( 0, $errors['readme.md'][0] );
$this->assertArrayHasKey( 'code', $errors['readme.md'][0][0][1] );
$this->assertEquals( 'stable_tag_mismatch', $errors['readme.md'][0][0][1]['code'] );
}

public function test_run_root_readme_file_without_errors() {
Expand Down

0 comments on commit 32b69c2

Please sign in to comment.