Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -754,9 +754,8 @@ private function check_for_contributors( Check_Result $result, string $readme_fi
return;
}

$usernames = explode( ',', $matches[1] );

$usernames = array_unique( array_map( 'trim', $usernames ) );
$usernames = explode( ',', trim( $matches[1], ' ,' ) );
$usernames = array_filter( array_unique( array_map( 'trim', $usernames ) ) );

$valid = true;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* Plugin Name: Test Plugin Readme Contributors Formatting
* Plugin URI: https://github.com/WordPress/plugin-check
* Description: Test plugin for the Readme check contributors formatting functionality.
* 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-contributors-formatting
*
* @package test-plugin-check-contributors-formatting
*/

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=== Test Plugin Readme Contributors Formatting ===

Contributors: johndoe, janedoe,
Requires at least: 6.0 or above
Tested up to: 6.6
Requires PHP: 5.6
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: testing, security

Plugin description.

13 changes: 13 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 @@ -608,6 +608,19 @@ public function test_run_without_errors_readme_contributors_warning() {
$this->assertCount( 0, wp_list_filter( $warnings['readme.txt'][0][0], array( 'code' => 'readme_invalid_contributors' ) ) );
}

public function test_run_without_errors_readme_contributors_formatting() {
$readme_check = new Plugin_Readme_Check();
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-readme-contributors-formatting/load.php' );
$check_result = new Check_Result( $check_context );

$readme_check->run( $check_result );

$warnings = $check_result->get_warnings();

// Should not contain contributors warning even with leading/trailing spaces and commas.
$this->assertCount( 0, wp_list_filter( $warnings['readme.txt'][0][0], array( 'code' => 'readme_invalid_contributors' ) ) );
}

public function test_run_with_mismatched_requires_headers() {
$check = new Plugin_Readme_Check();
$check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-trademarks-plugin-readme-errors/load.php' );
Expand Down
Loading