Skip to content

Commit

Permalink
Fix check for invalid MPL1 license
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Nov 7, 2024
1 parent 8a8b8b5 commit 79c10db
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
*/
class Plugin_Header_Fields_Check implements Static_Check {

use License_Utils;
use Amend_Check_Result;
use License_Utils;
use Stable_Check;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function test_run_with_valid_requires_plugins_header() {
}
}

public function test_run_with_invalid_license() {
public function test_run_with_invalid_mpl1_license() {
$check = new Plugin_Header_Fields_Check();
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-mpl1-license-with-errors/load.php' );
$check_result = new Check_Result( $check_context );
Expand All @@ -70,6 +70,7 @@ public function test_run_with_invalid_license() {

$this->assertNotEmpty( $errors );

// Check for invalid license.
$this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_license' ) ) );
}
}
18 changes: 0 additions & 18 deletions tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,6 @@ public function test_run_without_error_mpl2_license() {
$this->assertEmpty( $errors );
}

public function test_run_with_errors_mpl1_license() {
$readme_check = new Plugin_Readme_Check();
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-mpl1-license-with-errors/load.php' );
$check_result = new Check_Result( $check_context );

$readme_check->run( $check_result );

$errors = $check_result->get_errors();

$this->assertNotEmpty( $errors );
$this->assertArrayHasKey( 'load.php', $errors );

// Check for invalid license.
$this->assertArrayHasKey( 0, $errors['load.php'] );
$this->assertArrayHasKey( 0, $errors['load.php'][0] );
$this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'invalid_license' ) ) );
}

public function test_run_with_errors_tested_upto() {
$readme_check = new Plugin_Readme_Check();
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-errors-tested-upto/load.php' );
Expand Down

0 comments on commit 79c10db

Please sign in to comment.