Skip to content

Commit

Permalink
Merge pull request #525 from ernilambar/524-readme-file
Browse files Browse the repository at this point in the history
Co-authored-by: ernilambar <[email protected]>
Co-authored-by: swissspidy <[email protected]>
  • Loading branch information
3 people authored Jul 15, 2024
2 parents 484855c + ef33016 commit de56bdd
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion includes/Traits/Find_Readme.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait Find_Readme {
*/
protected function filter_files_for_readme( array $files, $plugin_relative_path ) {
// Find the readme file.
$readme_list = preg_grep( '/readme\.(txt|md)$/i', $files );
$readme_list = preg_grep( '/\/readme\.(txt|md)$/i', $files );

// Filter the readme files located at root.
$potential_readme_files = array_filter(
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Plugin Name: Test Plugin Readme Errors (invalid readme)
* 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: GPLv2 or later
* License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* Text Domain: test-plugin-check-errors
*
* @package test-plugin-check-errors
*/
Empty file.
19 changes: 19 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 @@ -31,6 +31,25 @@ public function test_run_with_errors_no_readme() {
$this->assertEquals( 'no_plugin_readme', $warnings['readme.txt'][0][0][0]['code'] );
}

public function test_run_with_errors_invalid_readme_files() {
$readme_check = new Plugin_Readme_Check();
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-plugin-readme-errors-invalid-readme/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->assertEquals( 1, $check_result->get_warning_count() );

$this->assertArrayHasKey( 0, $warnings['readme.txt'] );
$this->assertArrayHasKey( 0, $warnings['readme.txt'][0] );
$this->assertArrayHasKey( 'code', $warnings['readme.txt'][0][0][0] );
$this->assertSame( 'no_plugin_readme', $warnings['readme.txt'][0][0][0]['code'] );
}

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

0 comments on commit de56bdd

Please sign in to comment.