Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp option - new autoload values in autoload filter #515

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
50 changes: 50 additions & 0 deletions features/option-list.feature
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,53 @@ Feature: List WordPress options
option_value:
value: 1
"""

Scenario: Using the `--autoload=on` flag
Given a WP install
And I run `wp option add sample_autoload_one 'sample_value_one' --autoload=yes`
And I run `wp option add sample_autoload_two 'sample_value_two' --autoload=no`
And I run `wp option add sample_autoload_three 'sample_value_three' --autoload=on`
And I run `wp option add sample_autoload_four 'sample_value_four' --autoload=off`

When I run `wp option list --autoload=on`
Then STDOUT should not contain:
"""
sample_value_two
"""
And STDOUT should not contain:
"""
sample_value_four
"""
And STDOUT should contain:
"""
sample_value_one
"""
And STDOUT should contain:
"""
sample_value_three
"""

Scenario: Using the `--autoload=off` flag
Given a WP install
And I run `wp option add sample_autoload_one 'sample_value_one' --autoload=yes`
And I run `wp option add sample_autoload_two 'sample_value_two' --autoload=no`
And I run `wp option add sample_autoload_three 'sample_value_three' --autoload=on`
And I run `wp option add sample_autoload_four 'sample_value_four' --autoload=off`

When I run `wp option list --autoload=off`
Then STDOUT should not contain:
"""
sample_value_one
"""
And STDOUT should not contain:
"""
sample_value_three
"""
And STDOUT should contain:
"""
sample_value_two
"""
And STDOUT should contain:
"""
sample_value_four
"""
4 changes: 2 additions & 2 deletions src/Option_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ public function list_( $args, $assoc_args ) {
if ( isset( $assoc_args['autoload'] ) ) {
$autoload = $assoc_args['autoload'];
if ( 'on' === $autoload || 'yes' === $autoload ) {
$autoload_query = " AND autoload='yes'";
$autoload_query = " AND (autoload='on') OR (autoload='yes')";
} elseif ( 'off' === $autoload || 'no' === $autoload ) {
$autoload_query = " AND autoload='no'";
$autoload_query = " AND (autoload='off') OR (autoload='no')";
} else {
WP_CLI::error( "Value of '--autoload' should be 'on', 'off', 'yes', or 'no'." );
}
Expand Down
Loading