diff --git a/tests/phpunit/testdata/plugins/test-plugin-plugin-readme-errors-invalid-license/load.php b/tests/phpunit/testdata/plugins/test-plugin-plugin-readme-errors-invalid-license/load.php new file mode 100644 index 00000000..f0bbe86c --- /dev/null +++ b/tests/phpunit/testdata/plugins/test-plugin-plugin-readme-errors-invalid-license/load.php @@ -0,0 +1,15 @@ +assertCount( 1, wp_list_filter( $warnings['load.php'][0][0], array( 'code' => 'license_mismatch' ) ) ); } + + public function test_run_with_errors_invalid_license() { + $check = new Plugin_Header_Fields_Check(); + $check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-errors-invalid-license/load.php' ); + $check_result = new Check_Result( $check_context ); + + $check->run( $check_result ); + + $errors = $check_result->get_errors(); + + $this->assertNotEmpty( $errors ); + $this->assertArrayHasKey( 'load.php', $errors ); + + $this->assertCount( 1, wp_list_filter( $errors['load.php'][0][0], array( 'code' => 'plugin_header_invalid_license' ) ) ); + } } diff --git a/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php index 59ada1c6..52128df7 100644 --- a/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php @@ -177,6 +177,21 @@ public function test_run_with_errors_no_license() { $this->assertCount( 1, wp_list_filter( $errors['readme.txt'][0][0], array( 'code' => 'no_license' ) ) ); } + public function test_run_with_errors_invalid_license() { + $readme_check = new Plugin_Readme_Check(); + $check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-errors-invalid-license/load.php' ); + $check_result = new Check_Result( $check_context ); + + $readme_check->run( $check_result ); + + $warnings = $check_result->get_warnings(); + + $this->assertNotEmpty( $warnings ); + $this->assertArrayHasKey( 'readme.txt', $warnings ); + + $this->assertCount( 1, wp_list_filter( $warnings['readme.txt'][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' );