Skip to content

Commit 971ebf7

Browse files
Merge pull request #772 from WordPress/license-error-type
Change error type for License check error codes
2 parents bdd11e0 + 3322caa commit 971ebf7

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ private function check_license( Check_Result $result, string $readme_file, Parse
326326

327327
// Test for a valid SPDX license identifier.
328328
if ( ! $this->is_license_valid_identifier( $license ) ) {
329-
$this->add_result_warning_for_file(
329+
$this->add_result_error_for_file(
330330
$result,
331331
__( '<strong>Your plugin has an invalid license declared.</strong><br>Please update your readme with a valid SPDX license identifier.', 'plugin-check' ),
332332
'invalid_license',
@@ -371,7 +371,7 @@ private function check_license( Check_Result $result, string $readme_file, Parse
371371

372372
// Check different license types.
373373
if ( ! empty( $plugin_license ) && ! empty( $license ) && $license !== $plugin_license ) {
374-
$this->add_result_warning_for_file(
374+
$this->add_result_error_for_file(
375375
$result,
376376
__( '<strong>Your plugin has a different license declared in the readme file and plugin header.</strong><br>Please update your readme with a valid GPL license identifier.', 'plugin-check' ),
377377
'license_mismatch',

tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,18 @@ public function test_run_with_errors_license() {
148148

149149
$readme_check->run( $check_result );
150150

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

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

156-
// Check for invalid license warning.
157-
$this->assertArrayHasKey( 0, $warnings['readme.txt'] );
158-
$this->assertArrayHasKey( 0, $warnings['readme.txt'][0] );
159-
$this->assertCount( 1, wp_list_filter( $warnings['readme.txt'][0][0], array( 'code' => 'invalid_license' ) ) );
156+
// Check for invalid license.
157+
$this->assertArrayHasKey( 0, $errors['readme.txt'] );
158+
$this->assertArrayHasKey( 0, $errors['readme.txt'][0] );
159+
$this->assertCount( 1, wp_list_filter( $errors['readme.txt'][0][0], array( 'code' => 'invalid_license' ) ) );
160160

161-
// Check for not same license warning.
162-
$this->assertCount( 1, wp_list_filter( $warnings['readme.txt'][0][0], array( 'code' => 'license_mismatch' ) ) );
161+
// Check for not same license.
162+
$this->assertCount( 1, wp_list_filter( $errors['readme.txt'][0][0], array( 'code' => 'license_mismatch' ) ) );
163163
}
164164

165165
public function test_run_with_errors_no_license() {
@@ -244,12 +244,12 @@ public function test_run_md_with_errors() {
244244
$this->assertCount( 1, wp_list_filter( $errors['readme.md'][0][0], array( 'code' => 'trunk_stable_tag' ) ) );
245245
$this->assertCount( 1, wp_list_filter( $errors['readme.md'][0][0], array( 'code' => 'outdated_tested_upto_header' ) ) );
246246
$this->assertCount( 1, wp_list_filter( $errors['readme.md'][0][0], array( 'code' => 'default_readme_text' ) ) );
247+
$this->assertCount( 1, wp_list_filter( $errors['readme.md'][0][0], array( 'code' => 'invalid_license' ) ) );
248+
$this->assertCount( 1, wp_list_filter( $errors['readme.md'][0][0], array( 'code' => 'license_mismatch' ) ) );
247249

248250
$this->assertNotEmpty( $warnings );
249251
$this->assertArrayHasKey( 'readme.md', $warnings );
250252

251-
$this->assertCount( 1, wp_list_filter( $warnings['readme.md'][0][0], array( 'code' => 'invalid_license' ) ) );
252-
$this->assertCount( 1, wp_list_filter( $warnings['readme.md'][0][0], array( 'code' => 'license_mismatch' ) ) );
253253
$this->assertCount( 1, wp_list_filter( $warnings['readme.md'][0][0], array( 'code' => 'mismatched_plugin_name' ) ) );
254254
$this->assertCount( 1, wp_list_filter( $warnings['readme.md'][0][0], array( 'code' => 'readme_invalid_contributors' ) ) );
255255
}

0 commit comments

Comments
 (0)