From ba3e5cc9be10c3a6fe95585fe39ee55a132a3c08 Mon Sep 17 00:00:00 2001 From: rajkp Date: Tue, 22 Oct 2024 12:55:39 +0530 Subject: [PATCH 1/5] Fix: change the old option values to newer values --- src/Option_Command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Option_Command.php b/src/Option_Command.php index 072abca4..ea175ebb 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'"; } elseif ( 'off' === $autoload || 'no' === $autoload ) { - $autoload_query = " AND autoload='no'"; + $autoload_query = " AND autoload='off'"; } else { WP_CLI::error( "Value of '--autoload' should be 'on', 'off', 'yes', or 'no'." ); } From 61eb5001f26d2aa08c56cbb5f5c7f98bddabc7d5 Mon Sep 17 00:00:00 2001 From: rajkp Date: Wed, 23 Oct 2024 13:59:27 +0530 Subject: [PATCH 2/5] fix: also search for old values --- src/Option_Command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Option_Command.php b/src/Option_Command.php index ea175ebb..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='on'"; + $autoload_query = " AND (autoload='on') OR (autoload='yes')"; } elseif ( 'off' === $autoload || 'no' === $autoload ) { - $autoload_query = " AND autoload='off'"; + $autoload_query = " AND (autoload='off') OR (autoload='no')"; } else { WP_CLI::error( "Value of '--autoload' should be 'on', 'off', 'yes', or 'no'." ); } From a5e51e030cb4060441c45eaa323785178e4c9117 Mon Sep 17 00:00:00 2001 From: rajkp Date: Mon, 4 Nov 2024 21:52:23 +0530 Subject: [PATCH 3/5] Add test case scenarios for --autoload flag --- features/option-list.feature | 292 ++++++++++++++++++++--------------- 1 file changed, 170 insertions(+), 122 deletions(-) diff --git a/features/option-list.feature b/features/option-list.feature index 539352f7..3fa6eb9a 100644 --- a/features/option-list.feature +++ b/features/option-list.feature @@ -1,150 +1,198 @@ Feature: List WordPress options - Scenario: Using the `--transients` flag + # Scenario: Using the `--transients` flag + # Given a WP install + # And I run `wp transient set wp_transient_flag wp_transient_flag` + + # When I run `wp option list --no-transients` + # Then STDOUT should not contain: + # """ + # wp_transient_flag + # """ + # And STDOUT should not contain: + # """ + # _transient + # """ + # And STDOUT should contain: + # """ + # siteurl + # """ + + # When I run `wp option list --transients` + # Then STDOUT should contain: + # """ + # wp_transient_flag + # """ + # And STDOUT should contain: + # """ + # _transient + # """ + # And STDOUT should not contain: + # """ + # siteurl + # """ + + # Scenario: List option with exclude pattern + # Given a WP install + + # When I run `wp option add sample_test_field_one sample_test_field_value_one` + # And I run `wp option add sample_test_field_two sample_test_field_value_two` + # And I run `wp option list --search="sample_test_field_*" --format=csv` + # Then STDOUT should be: + # """ + # option_name,option_value + # sample_test_field_one,sample_test_field_value_one + # sample_test_field_two,sample_test_field_value_two + # """ + + # When I run `wp option list --search="sample_test_field_*" --exclude="*field_one" --format=csv` + # Then STDOUT should be: + # """ + # option_name,option_value + # sample_test_field_two,sample_test_field_value_two + # """ + + # When I run `wp option list` + # Then STDOUT should contain: + # """ + # sample_test_field_one + # """ + + # When I run `wp option list --exclude="sample_test_field_one"` + # Then STDOUT should not contain: + # """ + # sample_test_field_one + # """ + + # Scenario: List option with sorting option + # Given a WP install + # And I run `wp option add sample_test_field_one sample_test_field_value_one` + # And I run `wp option add sample_test_field_two sample_test_field_value_two` + + # When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_id --order=asc` + # Then STDOUT should be: + # """ + # option_name,option_value + # sample_test_field_one,sample_test_field_value_one + # sample_test_field_two,sample_test_field_value_two + # """ + + # When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_id --order=desc` + # Then STDOUT should be: + # """ + # option_name,option_value + # sample_test_field_two,sample_test_field_value_two + # sample_test_field_one,sample_test_field_value_one + # """ + + # When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_name --order=asc` + # Then STDOUT should be: + # """ + # option_name,option_value + # sample_test_field_one,sample_test_field_value_one + # sample_test_field_two,sample_test_field_value_two + # """ + + # When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_name --order=desc` + # Then STDOUT should be: + # """ + # option_name,option_value + # sample_test_field_two,sample_test_field_value_two + # sample_test_field_one,sample_test_field_value_one + # """ + + # When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_value --order=asc` + # Then STDOUT should be: + # """ + # option_name,option_value + # sample_test_field_one,sample_test_field_value_one + # sample_test_field_two,sample_test_field_value_two + # """ + + # When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_value --order=desc` + # Then STDOUT should be: + # """ + # option_name,option_value + # sample_test_field_two,sample_test_field_value_two + # sample_test_field_one,sample_test_field_value_one + # """ + + # Scenario: Default list option without transient + # Given a WP install + # And I run `wp transient set wp_transient_flag wp_transient_flag` + + # When I run `wp option list` + # Then STDOUT should not contain: + # """ + # wp_transient_flag + # """ + # And STDOUT should not contain: + # """ + # _transient + # """ + # And STDOUT should contain: + # """ + # siteurl + # """ + + # Scenario: Using the `--unserialize` flag + # Given a WP install + + # When I run `wp option add --format=json sample_test_field_one '{"value": 1}'` + # And I run `wp option list --search="sample_test_field_*" --format=yaml --unserialize` + # Then STDOUT should be: + # """ + # --- + # - + # option_name: sample_test_field_one + # option_value: + # value: 1 + # """ + Scenario: Using the `--autoload=on` flag Given a WP install - And I run `wp transient set wp_transient_flag wp_transient_flag` + 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 --no-transients` + When I run `wp option list --autoload=on` Then STDOUT should not contain: """ - wp_transient_flag + sample_value_two """ And STDOUT should not contain: """ - _transient + sample_value_four """ And STDOUT should contain: """ - siteurl - """ - - When I run `wp option list --transients` - Then STDOUT should contain: - """ - wp_transient_flag + sample_value_one """ And STDOUT should contain: """ - _transient - """ - And STDOUT should not contain: - """ - siteurl + sample_value_three """ - - Scenario: List option with exclude pattern + 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 add sample_test_field_one sample_test_field_value_one` - And I run `wp option add sample_test_field_two sample_test_field_value_two` - And I run `wp option list --search="sample_test_field_*" --format=csv` - Then STDOUT should be: - """ - option_name,option_value - sample_test_field_one,sample_test_field_value_one - sample_test_field_two,sample_test_field_value_two - """ - - When I run `wp option list --search="sample_test_field_*" --exclude="*field_one" --format=csv` - Then STDOUT should be: - """ - option_name,option_value - sample_test_field_two,sample_test_field_value_two - """ - - When I run `wp option list` - Then STDOUT should contain: - """ - sample_test_field_one - """ - - When I run `wp option list --exclude="sample_test_field_one"` + When I run `wp option list --autoload=off` Then STDOUT should not contain: """ - sample_test_field_one - """ - - Scenario: List option with sorting option - Given a WP install - And I run `wp option add sample_test_field_one sample_test_field_value_one` - And I run `wp option add sample_test_field_two sample_test_field_value_two` - - When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_id --order=asc` - Then STDOUT should be: - """ - option_name,option_value - sample_test_field_one,sample_test_field_value_one - sample_test_field_two,sample_test_field_value_two - """ - - When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_id --order=desc` - Then STDOUT should be: - """ - option_name,option_value - sample_test_field_two,sample_test_field_value_two - sample_test_field_one,sample_test_field_value_one - """ - - When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_name --order=asc` - Then STDOUT should be: - """ - option_name,option_value - sample_test_field_one,sample_test_field_value_one - sample_test_field_two,sample_test_field_value_two - """ - - When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_name --order=desc` - Then STDOUT should be: - """ - option_name,option_value - sample_test_field_two,sample_test_field_value_two - sample_test_field_one,sample_test_field_value_one - """ - - When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_value --order=asc` - Then STDOUT should be: - """ - option_name,option_value - sample_test_field_one,sample_test_field_value_one - sample_test_field_two,sample_test_field_value_two - """ - - When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_value --order=desc` - Then STDOUT should be: - """ - option_name,option_value - sample_test_field_two,sample_test_field_value_two - sample_test_field_one,sample_test_field_value_one - """ - - Scenario: Default list option without transient - Given a WP install - And I run `wp transient set wp_transient_flag wp_transient_flag` - - When I run `wp option list` - Then STDOUT should not contain: - """ - wp_transient_flag + sample_value_one """ And STDOUT should not contain: """ - _transient + sample_value_three """ And STDOUT should contain: """ - siteurl + sample_value_two """ - - Scenario: Using the `--unserialize` flag - Given a WP install - - When I run `wp option add --format=json sample_test_field_one '{"value": 1}'` - And I run `wp option list --search="sample_test_field_*" --format=yaml --unserialize` - Then STDOUT should be: - """ - --- - - - option_name: sample_test_field_one - option_value: - value: 1 + And STDOUT should contain: """ + sample_value_four + """ \ No newline at end of file From 1882e6287f4fd6c50a923e2c23b3f2293a8b4dda Mon Sep 17 00:00:00 2001 From: rajkp Date: Mon, 4 Nov 2024 21:52:23 +0530 Subject: [PATCH 4/5] Add test case scenarios for --autoload flag --- features/option-list.feature | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/features/option-list.feature b/features/option-list.feature index 539352f7..ace6da91 100644 --- a/features/option-list.feature +++ b/features/option-list.feature @@ -148,3 +148,52 @@ 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 From f607f7666b2496c2d3e1d008c4cfd8abe84a6b45 Mon Sep 17 00:00:00 2001 From: rajkp Date: Tue, 5 Nov 2024 10:54:10 +0530 Subject: [PATCH 5/5] Fix the testcases for the --autolaod flag in option list command --- features/option-list.feature | 49 ------------------------------------ 1 file changed, 49 deletions(-) diff --git a/features/option-list.feature b/features/option-list.feature index d21a769c..5e285730 100644 --- a/features/option-list.feature +++ b/features/option-list.feature @@ -173,54 +173,7 @@ Feature: List WordPress options """ 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: - """ -<<<<<<< HEAD - - 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` @@ -243,7 +196,5 @@ Feature: List WordPress options """ And STDOUT should contain: """ -======= ->>>>>>> a5e51e030cb4060441c45eaa323785178e4c9117 sample_value_four """ \ No newline at end of file