|
| 1 | +Feature: Manage WordPress options |
| 2 | + |
| 3 | + Scenario: Option CRUD |
| 4 | + Given a WP install |
| 5 | + |
| 6 | + # String values |
| 7 | + When I run `wp option add str_opt 'bar'` |
| 8 | + Then STDOUT should not be empty |
| 9 | + |
| 10 | + When I run `wp option get str_opt` |
| 11 | + Then STDOUT should be: |
| 12 | + """ |
| 13 | + bar |
| 14 | + """ |
| 15 | + |
| 16 | + When I run `wp option list` |
| 17 | + Then STDOUT should not be empty |
| 18 | + |
| 19 | + When I run `wp option list` |
| 20 | + Then STDOUT should contain: |
| 21 | + """ |
| 22 | + str_opt bar |
| 23 | + """ |
| 24 | + |
| 25 | + When I run `wp option list --autoload=off` |
| 26 | + Then STDOUT should not contain: |
| 27 | + """ |
| 28 | + str_opt bar |
| 29 | + """ |
| 30 | + |
| 31 | + When I run `wp option list --search='str_o*'` |
| 32 | + Then STDOUT should be a table containing rows: |
| 33 | + | option_name | option_value | |
| 34 | + | str_opt | bar | |
| 35 | + |
| 36 | + When I run `wp option list --search='str_o*' --format=total_bytes` |
| 37 | + Then STDOUT should be: |
| 38 | + """ |
| 39 | + 3 |
| 40 | + """ |
| 41 | + |
| 42 | + When I run `wp option list` |
| 43 | + Then STDOUT should contain: |
| 44 | + """ |
| 45 | + home http://example.com |
| 46 | + """ |
| 47 | + |
| 48 | + When I run `wp option add auto_opt --autoload=no 'bar'` |
| 49 | + Then STDOUT should not be empty |
| 50 | + |
| 51 | + When I run `wp option list --search='auto_opt' --autoload` |
| 52 | + Then STDOUT should not be empty |
| 53 | + |
| 54 | + When I run `wp option list | grep -q "str_opt"` |
| 55 | + Then the return code should be 0 |
| 56 | + |
| 57 | + When I run `wp option delete str_opt` |
| 58 | + Then STDOUT should not be empty |
| 59 | + |
| 60 | + When I run `wp option list` |
| 61 | + Then STDOUT should not contain: |
| 62 | + """ |
| 63 | + str_opt bar |
| 64 | + """ |
| 65 | + |
| 66 | + When I try `wp option get str_opt` |
| 67 | + Then the return code should be 1 |
| 68 | + |
| 69 | + # Integer values |
| 70 | + When I run `wp option update blog_public 1` |
| 71 | + Then STDOUT should not be empty |
| 72 | + |
| 73 | + When I run `wp option update blog_public 0` |
| 74 | + Then STDOUT should contain: |
| 75 | + """ |
| 76 | + Success: Updated 'blog_public' option. |
| 77 | + """ |
| 78 | + |
| 79 | + When I run the previous command again |
| 80 | + Then STDOUT should contain: |
| 81 | + """ |
| 82 | + Success: Value passed for 'blog_public' option is unchanged. |
| 83 | + """ |
| 84 | + |
| 85 | + When I run `wp option get blog_public` |
| 86 | + Then STDOUT should be: |
| 87 | + """ |
| 88 | + 0 |
| 89 | + """ |
| 90 | + |
| 91 | + |
| 92 | + # JSON values |
| 93 | + When I run `wp option set json_opt '[ 1, 2 ]' --format=json` |
| 94 | + Then STDOUT should not be empty |
| 95 | + |
| 96 | + When I run the previous command again |
| 97 | + Then STDOUT should not be empty |
| 98 | + |
| 99 | + When I run `wp option get json_opt --format=json` |
| 100 | + Then STDOUT should be: |
| 101 | + """ |
| 102 | + [1,2] |
| 103 | + """ |
| 104 | + |
| 105 | + |
| 106 | + # Reading from files |
| 107 | + Given a value.json file: |
| 108 | + """ |
| 109 | + { |
| 110 | + "foo": "bar", |
| 111 | + "list": [1, 2, 3] |
| 112 | + } |
| 113 | + """ |
| 114 | + When I run `wp option set foo --format=json < value.json` |
| 115 | + And I run `wp option get foo --format=json` |
| 116 | + Then STDOUT should be JSON containing: |
| 117 | + """ |
| 118 | + { |
| 119 | + "foo": "bar", |
| 120 | + "list": [1, 2, 3] |
| 121 | + } |
| 122 | + """ |
| 123 | +
|
| 124 | + @require-wp-4.2 |
| 125 | + Scenario: Update autoload value for custom option |
| 126 | + Given a WP install |
| 127 | + And I run `wp option add hello world --autoload=no` |
| 128 | +
|
| 129 | + When I run `wp option update hello universe` |
| 130 | + Then STDOUT should not be empty |
| 131 | +
|
| 132 | + When I run `wp option list --search='hello' --fields=option_name,option_value,autoload` |
| 133 | + Then STDOUT should be a table containing rows: |
| 134 | + | option_name | option_value | autoload | |
| 135 | + | hello | universe | no | |
| 136 | +
|
| 137 | + When I run `wp option update hello island --autoload=yes` |
| 138 | + Then STDOUT should not be empty |
| 139 | +
|
| 140 | + When I run `wp option list --search='hello' --fields=option_name,option_value,autoload` |
| 141 | + Then STDOUT should be a table containing rows: |
| 142 | + | option_name | option_value | autoload | |
| 143 | + | hello | island | yes | |
| 144 | +
|
| 145 | + @require-wp-4.2 |
| 146 | + Scenario: Managed autoloaded options |
| 147 | + Given a WP install |
| 148 | +
|
| 149 | + When I run `wp option add wp_autoload_1 enabled --autoload=yes` |
| 150 | + Then STDOUT should be: |
| 151 | + """ |
| 152 | + Success: Added 'wp_autoload_1' option. |
| 153 | + """ |
| 154 | + And STDERR should be empty |
| 155 | +
|
| 156 | + When I run `wp option add wp_autoload_2 implicit` |
| 157 | + Then STDOUT should be: |
| 158 | + """ |
| 159 | + Success: Added 'wp_autoload_2' option. |
| 160 | + """ |
| 161 | + And STDERR should be empty |
| 162 | +
|
| 163 | + When I run `wp option add wp_autoload_3 disabled --autoload=no` |
| 164 | + Then STDOUT should be: |
| 165 | + """ |
| 166 | + Success: Added 'wp_autoload_3' option. |
| 167 | + """ |
| 168 | + And STDERR should be empty |
| 169 | +
|
| 170 | + When I run `wp option list --search='wp_autoload*' --fields=option_name,option_value,autoload` |
| 171 | + Then STDOUT should be a table containing rows: |
| 172 | + | option_name | option_value | autoload | |
| 173 | + | wp_autoload_1 | enabled | yes | |
| 174 | + | wp_autoload_2 | implicit | yes | |
| 175 | + | wp_autoload_3 | disabled | no | |
| 176 | +
|
| 177 | + When I run `wp option update wp_autoload_1 disabled --autoload=no` |
| 178 | + Then STDOUT should be: |
| 179 | + """ |
| 180 | + Success: Updated 'wp_autoload_1' option. |
| 181 | + """ |
| 182 | + And STDERR should be empty |
| 183 | +
|
| 184 | + When I run `wp option update wp_autoload_2 implicit2` |
| 185 | + Then STDOUT should be: |
| 186 | + """ |
| 187 | + Success: Updated 'wp_autoload_2' option. |
| 188 | + """ |
| 189 | + And STDERR should be empty |
| 190 | +
|
| 191 | + When I run `wp option update wp_autoload_3 enabled --autoload=yes` |
| 192 | + Then STDOUT should be: |
| 193 | + """ |
| 194 | + Success: Updated 'wp_autoload_3' option. |
| 195 | + """ |
| 196 | + And STDERR should be empty |
| 197 | +
|
| 198 | + When I run `wp option list --search='wp_autoload*' --fields=option_name,option_value,autoload` |
| 199 | + Then STDOUT should be a table containing rows: |
| 200 | + | option_name | option_value | autoload | |
| 201 | + | wp_autoload_1 | disabled | no | |
| 202 | + | wp_autoload_2 | implicit2 | yes | |
| 203 | + | wp_autoload_3 | enabled | yes | |
| 204 | +
|
| 205 | + Scenario: Extra removetrailingslash sanitization for whitelisted options |
| 206 | + Given a WP install |
| 207 | +
|
| 208 | + When I run `wp option update home 'http://localhost/'` |
| 209 | + Then STDOUT should be: |
| 210 | + """ |
| 211 | + Success: Updated 'home' option. |
| 212 | + """ |
| 213 | +
|
| 214 | + When I run `wp option update home 'http://localhost/'` |
| 215 | + Then STDOUT should be: |
| 216 | + """ |
| 217 | + Success: Value passed for 'home' option is unchanged. |
| 218 | + """ |
0 commit comments