-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathoption.feature
More file actions
294 lines (242 loc) · 8.17 KB
/
option.feature
File metadata and controls
294 lines (242 loc) · 8.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
Feature: Manage WordPress options
Scenario: Option CRUD
Given a WP install
# String values
When I run `wp option add str_opt 'bar'`
Then STDOUT should not be empty
When I run `wp option get str_opt`
Then STDOUT should be:
"""
bar
"""
When I run `wp option list`
Then STDOUT should not be empty
When I run `wp option list`
Then STDOUT should contain:
"""
str_opt bar
"""
When I run `wp option list --autoload=off`
Then STDOUT should not contain:
"""
str_opt bar
"""
When I run `wp option list --search='str_o*'`
Then STDOUT should be a table containing rows:
| option_name | option_value |
| str_opt | bar |
When I run `wp option list --search='str_o*' --format=total_bytes`
Then STDOUT should be:
"""
3
"""
When I run `wp option list`
Then STDOUT should contain:
"""
home https://example.com
"""
When I run `wp option add auto_opt --autoload=no 'bar'`
Then STDOUT should not be empty
When I run `wp option list --search='auto_opt' --autoload=off`
Then STDOUT should not be empty
When I run `wp option list | grep -q "str_opt"`
Then the return code should be 0
When I run `wp option delete str_opt`
Then STDOUT should not be empty
When I run `wp option add option_one "ONE"`
And I run `wp option add option_two "TWO"`
Then STDOUT should not be empty
When I try `wp option delete option_one option_two option_three`
Then STDOUT should be:
"""
Success: Deleted 'option_one' option.
Success: Deleted 'option_two' option.
"""
And STDERR should be:
"""
Warning: Could not delete 'option_three' option. Does it exist?
"""
When I run `wp option list`
Then STDOUT should not contain:
"""
str_opt bar
"""
When I try `wp option get str_opt`
Then STDERR should be:
"""
Error: Could not get 'str_opt' option. Does it exist?
"""
# Integer values
When I run `wp option update blog_public 1`
Then STDOUT should not be empty
When I run `wp option update blog_public 0`
Then STDOUT should contain:
"""
Success: Updated 'blog_public' option.
"""
When I run the previous command again
Then STDOUT should contain:
"""
Success: Value passed for 'blog_public' option is unchanged.
"""
When I run `wp option get blog_public`
Then STDOUT should be:
"""
0
"""
# JSON values
When I run `wp option set json_opt '[ 1, 2 ]' --format=json`
Then STDOUT should not be empty
When I run the previous command again
Then STDOUT should not be empty
When I run `wp option get json_opt --format=json`
Then STDOUT should be:
"""
[1,2]
"""
# Reading from files
Given a value.json file:
"""
{
"foo": "bar",
"list": [1, 2, 3]
}
"""
When I run `wp option set foo --format=json < value.json`
And I run `wp option get foo --format=json`
Then STDOUT should be JSON containing:
"""
{
"foo": "bar",
"list": [1, 2, 3]
}
"""
@require-wp-4.2
@less-than-wp-6.6
Scenario: Update autoload value for custom option
Given a WP install
And I run `wp option add hello world --autoload=no`
When I run `wp option update hello universe`
Then STDOUT should not be empty
When I run `wp option list --search='hello' --fields=option_name,option_value,autoload`
Then STDOUT should be a table containing rows:
| option_name | option_value | autoload |
| hello | universe | no |
When I run `wp option update hello island --autoload=yes`
Then STDOUT should not be empty
When I run `wp option list --search='hello' --fields=option_name,option_value,autoload`
Then STDOUT should be a table containing rows:
| option_name | option_value | autoload |
| hello | island | yes |
@require-wp-6.6
Scenario: Update autoload value for custom option
Given a WP install
And I run `wp option add hello world --autoload=off`
When I run `wp option update hello universe`
Then STDOUT should not be empty
When I run `wp option list --search='hello' --fields=option_name,option_value,autoload`
Then STDOUT should be a table containing rows:
| option_name | option_value | autoload |
| hello | universe | off |
When I run `wp option update hello island --autoload=on`
Then STDOUT should not be empty
When I run `wp option list --search='hello' --fields=option_name,option_value,autoload`
Then STDOUT should be a table containing rows:
| option_name | option_value | autoload |
| hello | island | on |
@require-wp-4.2
@less-than-wp-6.6
Scenario: Managed autoloaded options
Given a WP install
When I run `wp option add wp_autoload_1 enabled --autoload=yes`
Then STDOUT should be:
"""
Success: Added 'wp_autoload_1' option.
"""
And STDERR should be empty
When I run `wp option add wp_autoload_2 implicit`
Then STDOUT should be:
"""
Success: Added 'wp_autoload_2' option.
"""
And STDERR should be empty
When I run `wp option add wp_autoload_3 disabled --autoload=no`
Then STDOUT should be:
"""
Success: Added 'wp_autoload_3' option.
"""
And STDERR should be empty
When I run `wp option list --search='wp_autoload*' --fields=option_name,option_value,autoload`
Then STDOUT should be a table containing rows:
| option_name | option_value | autoload |
| wp_autoload_1 | enabled | yes |
| wp_autoload_2 | implicit | yes |
| wp_autoload_3 | disabled | no |
When I run `wp option update wp_autoload_1 disabled --autoload=no`
Then STDOUT should be:
"""
Success: Updated 'wp_autoload_1' option.
"""
And STDERR should be empty
When I run `wp option update wp_autoload_2 implicit2`
Then STDOUT should be:
"""
Success: Updated 'wp_autoload_2' option.
"""
And STDERR should be empty
When I run `wp option update wp_autoload_3 enabled --autoload=yes`
Then STDOUT should be:
"""
Success: Updated 'wp_autoload_3' option.
"""
And STDERR should be empty
When I run `wp option list --search='wp_autoload*' --fields=option_name,option_value,autoload`
Then STDOUT should be a table containing rows:
| option_name | option_value | autoload |
| wp_autoload_1 | disabled | no |
| wp_autoload_2 | implicit2 | yes |
| wp_autoload_3 | enabled | yes |
Scenario: Extra removetrailingslash sanitization for whitelisted options
Given a WP install
When I run `wp option update home 'http://localhost/'`
Then STDOUT should be:
"""
Success: Updated 'home' option.
"""
When I run `wp option update home 'http://localhost/'`
Then STDOUT should be:
"""
Success: Value passed for 'home' option is unchanged.
"""
Scenario: Bad values for autoload
Given a WP install
When I run `wp option add str_opt 'bar'`
Then STDOUT should not be empty
When I try `wp option list --search='auto_opt' --autoload`
Then STDOUT should not be empty
And STDERR should be:
"""
Warning: --autoload parameter needs a value
"""
And the return code should be 0
When I try `wp option list --search='auto_opt' --autoload=nope`
Then STDOUT should be empty
And STDERR should contain:
"""
Error: Value of '--autoload' should be
"""
And the return code should be 1
When I try `wp option add str_opt_foo 'bar' --autoload`
Then STDOUT should not be empty
And STDERR should be:
"""
Warning: --autoload parameter needs a value
"""
And the return code should be 0
When I try `wp option add str_opt_foo 'bar' --autoload=bad`
Then STDOUT should be empty
And STDERR should contain:
"""
Error: Parameter errors:
"""
And the return code should be 1