Skip to content

Commit

Permalink
Fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Oct 30, 2024
2 parents ab62ef1 + d186c69 commit a3d81a4
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Plugin Name: Test Plugin MPL-1.0 (license) with errors
* Plugin URI: https://github.com/WordPress/plugin-check
* Description: Test plugin for the Readme check.
* Requires at least: 6.0
* Requires PHP: 5.6
* Version: 1.0.0
* Author: WordPress Performance Team
* Author URI: https://make.wordpress.org/performance/
* License: MPL-1.0
* License URI: https://www.mozilla.org/en-US/MPL/2.0/FAQ/
* Text Domain: test-plugin-plugin-readme-mpl1-license-with-errors
*
* @package test-plugin-plugin-readme-mpl1-license-with-errors
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

=== Test Plugin with readme and MPL 1.0 license ===

Contributors: plugin-check
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 5.6
Stable tag: 1.0.0
License: MPL-1.0
License URI: https://www.mozilla.org/en-US/MPL/1.0/FAQ/
Tags: testing, security

Plugin description.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Plugin Name: Test Plugin MPL-2.0 (license) without errors
* Plugin URI: https://github.com/WordPress/plugin-check
* Description: Test plugin for the Readme check.
* Requires at least: 6.0
* Requires PHP: 5.6
* Version: 1.0.0
* Author: WordPress Performance Team
* Author URI: https://make.wordpress.org/performance/
* License: MPL-2.0
* License URI: https://www.mozilla.org/en-US/MPL/2.0/FAQ/
* Text Domain: test-plugin-plugin-readme-mpl2-license-without-errors
*
* @package test-plugin-plugin-readme-mpl2-license-without-errors
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

=== Test Plugin with readme and MPL 2.0 license ===

Contributors: plugin-check
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 5.6
Stable tag: 1.0.0
License: MPL-2.0
License URI: https://www.mozilla.org/en-US/MPL/2.0/FAQ/
Tags: testing, security

Plugin description.
30 changes: 30 additions & 0 deletions tests/phpunit/tests/Checker/Checks/Plugin_Readme_Check_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,36 @@ public function test_run_with_errors_invalid_license() {
$this->assertCount( 1, wp_list_filter( $warnings['readme.txt'][0][0], array( 'code' => 'invalid_license' ) ) );
}

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

$readme_check->run( $check_result );

$errors = $check_result->get_errors();

$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 a3d81a4

Please sign in to comment.