diff --git a/features/option-list.feature b/features/option-list.feature index 539352f7..5e285730 100644 --- a/features/option-list.feature +++ b/features/option-list.feature @@ -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 + """ \ No newline at end of file diff --git a/src/Option_Command.php b/src/Option_Command.php index 072abca4..73bc32b2 100644 --- a/src/Option_Command.php +++ b/src/Option_Command.php @@ -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'." ); }