Skip to content
Closed
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
16 changes: 16 additions & 0 deletions features/checksum-core.feature
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,19 @@ Feature: Validate checksums for WordPress install
Success: WordPress installation verifies against checksums.
"""
And the return code should be 0

Scenario: Verify core checksums with excluded files containing whitespace around comma separators
Given a WP install
And "WordPress" replaced with "PressWord" in the readme.html file
And a wp-includes/some-filename.php file:
"""
sample content of some file
"""

When I try `wp core verify-checksums --exclude='readme.html, wp-includes/some-filename.php'`
Then STDERR should be empty
And STDOUT should be:
"""
Success: WordPress installation verifies against checksums.
"""
And the return code should be 0
19 changes: 19 additions & 0 deletions features/checksum-plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,25 @@ Feature: Validate checksums for WordPress plugins
When I try `wp plugin verify-checksums --all --exclude=akismet`
Then STDOUT should match /^Success: Verified \d of \d plugins \(\d skipped\)\./

Scenario: Plugin verification is skipped when --exclude entries have surrounding whitespace
Given a WP install

When I run `wp plugin delete --all`
Then STDOUT should contain:
"""
Success:
"""

# Ignore plugin's version requirements because we don't actually activate it.
When I run `wp plugin install akismet --ignore-requirements`
Then STDOUT should contain:
"""
Success:
"""

When I try `wp plugin verify-checksums --all --exclude=' akismet'`
Then STDOUT should match /^Success: Verified \d of \d plugins \(\d skipped\)\./

Scenario: Plugin is verified when the --exclude argument isn't included
Given a WP install

Expand Down
2 changes: 1 addition & 1 deletion src/Checksum_Core_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function __invoke( $args, $assoc_args ) {
if ( ! empty( $assoc_args['exclude'] ) ) {
$exclude = Utils\get_flag_value( $assoc_args, 'exclude', '' );

$this->exclude_files = explode( ',', $exclude );
$this->exclude_files = array_map( 'trim', explode( ',', $exclude ) );
}

if ( empty( $wp_version ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/Checksum_Plugin_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function __invoke( $args, $assoc_args ) {
WP_CLI::error( 'You need to specify either one or more plugin slugs to check or use the --all flag to check all plugins.' );
}

$exclude_list = explode( ',', $exclude );
$exclude_list = array_map( 'trim', explode( ',', $exclude ) );

$skips = 0;

Expand Down
Loading