-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathwidget.feature
More file actions
242 lines (209 loc) · 8.08 KB
/
widget.feature
File metadata and controls
242 lines (209 loc) · 8.08 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
Feature: Manage widgets in WordPress sidebar
Background:
Given a WP install
And I try `wp theme delete twentytwelve --force`
And I run `wp theme install twentytwelve --activate`
And I try `wp widget reset --all`
And I try `wp widget delete wp_inactive_widgets $(wp widget list wp_inactive_widgets --format=ids)`
And I run `wp widget add text sidebar-1 --title="Text 1"`
And I run `wp widget add archives sidebar-1 --title="Archives"`
And I run `wp widget add calendar sidebar-1 --title="Calendar"`
And I run `wp widget add search sidebar-1 --title="Quick Search"`
And I run `wp widget add text sidebar-1 --title="Text 2"`
And I run `wp widget add search sidebar-2 --title="Quick Search"`
And I run `wp widget add text sidebar-3 --title="Text"`
@skip-windows
Scenario: Widget CRUD
When I run `wp widget list sidebar-1 --fields=name,id,position`
Then STDOUT should be a table containing rows:
| name | id | position |
| text | text-1 | 1 |
| archives | archives-1 | 2 |
| calendar | calendar-1 | 3 |
| search | search-1 | 4 |
| text | text-2 | 5 |
When I run `wp widget move search-1 --position=2`
Then STDOUT should not be empty
When I run `wp widget list sidebar-1 --fields=name,id,position`
Then STDOUT should be a table containing rows:
| name | id | position |
| text | text-1 | 1 |
| search | search-1 | 2 |
| archives | archives-1 | 3 |
| calendar | calendar-1 | 4 |
| text | text-2 | 5 |
When I run `wp widget move text-1 --sidebar-id=wp_inactive_widgets`
Then STDOUT should not be empty
When I run `wp widget deactivate calendar-1`
Then STDOUT should be:
"""
Success: Deactivated 1 of 1 widgets.
"""
And STDERR should be empty
And the return code should be 0
When I run `wp widget list sidebar-1 --fields=name,id,position`
Then STDOUT should be a table containing rows:
| name | id | position |
| search | search-1 | 1 |
| archives | archives-1 | 2 |
| text | text-2 | 3 |
When I run `wp widget list wp_inactive_widgets --fields=name,id,position`
# TODO: Investigate why calendar is at position 7 on Windows.
Then STDOUT should be a table containing rows:
| name | id | position |
| text | text-1 | 1 |
| calendar | calendar-1 | 2 |
When I run `wp widget delete archives-1 text-1`
Then STDOUT should be:
"""
Success: Deleted 2 of 2 widgets.
"""
And STDERR should be empty
And the return code should be 0
When I run `wp widget list sidebar-1 --fields=name,id,position`
Then STDOUT should be a table containing rows:
| name | id | position |
| search | search-1 | 1 |
| text | text-2 | 2 |
When I run `wp widget add archives sidebar-1 2 --title="Archives"`
Then STDOUT should not be empty
When I run `wp widget list sidebar-1 --fields=name,id,position`
Then STDOUT should be a table containing rows:
| name | id | position |
| search | search-1 | 1 |
| archives | archives-1 | 2 |
| text | text-2 | 3 |
When I run `wp widget list sidebar-1 --format=ids`
Then STDOUT should be:
"""
search-1 archives-1 text-2
"""
When I run `wp widget list sidebar-1 --fields=name,position,options`
Then STDOUT should be a table containing rows:
| name | position | options |
| archives | 2 | {"title":"Archives","count":0,"dropdown":0} |
When I run `wp widget update archives-1 --title="New Archives"`
Then STDOUT should not be empty
When I run `wp widget list sidebar-1 --fields=name,position,options`
Then STDOUT should be a table containing rows:
| name | position | options |
| archives | 2 | {"title":"New Archives","count":0,"dropdown":0} |
Scenario: Patch widget options
When I run `wp widget patch update archives-1 title "Patched Archives"`
Then STDOUT should be:
"""
Success: Widget updated.
"""
And STDERR should be empty
And the return code should be 0
When I run `wp widget list sidebar-1 --fields=name,position,options`
Then STDOUT should be a table containing rows:
| name | position | options |
| archives | 2 | {"title":"Patched Archives","count":0,"dropdown":0} |
When I run `wp widget patch insert archives-1 new_key "inserted value"`
Then STDOUT should be:
"""
Success: Widget updated.
"""
And STDERR should be empty
And the return code should be 0
When I run `wp widget patch delete archives-1 new_key`
Then STDOUT should be:
"""
Success: Widget updated.
"""
And STDERR should be empty
And the return code should be 0
# Read value to update from STDIN (edge case: "0")
When I run `echo '0' | wp widget patch update archives-1 title`
Then STDOUT should be:
"""
Success: Widget updated.
"""
And STDERR should be empty
And the return code should be 0
When I try `wp widget patch update calendar-999 title "Nope"`
Then STDERR should be:
"""
Error: Widget doesn't exist.
"""
And the return code should be 1
When I try `wp widget patch update archives-1 title`
Then STDERR should be:
"""
Error: Please provide a value to update.
"""
And the return code should be 1
Scenario: Validate sidebar widgets
When I try `wp widget update calendar-999`
Then STDERR should be:
"""
Error: Widget doesn't exist.
"""
And the return code should be 1
When I try `wp widget move calendar-999`
Then STDERR should be:
"""
Error: Widget doesn't exist.
"""
And the return code should be 1
Scenario: Return code is 0 when all widgets exist, deactivation
When I run `wp widget deactivate text-1`
Then STDOUT should be:
"""
Success: Deactivated 1 of 1 widgets.
"""
And STDERR should be empty
And the return code should be 0
When I run `wp widget deactivate archives-1 calendar-1`
Then STDOUT should be:
"""
Success: Deactivated 2 of 2 widgets.
"""
And STDERR should be empty
And the return code should be 0
Scenario: Return code is 0 when all widgets exist, deletion
When I run `wp widget delete text-1`
Then STDOUT should be:
"""
Success: Deleted 1 of 1 widgets.
"""
And STDERR should be empty
And the return code should be 0
When I run `wp widget delete archives-1 calendar-1`
Then STDOUT should be:
"""
Success: Deleted 2 of 2 widgets.
"""
And STDERR should be empty
And the return code should be 0
Scenario: Return code is 1 when 1 or more widgets doesn't exist, deactivation
When I try `wp widget deactivate calendar-999`
Then STDERR should be:
"""
Warning: Widget 'calendar-999' doesn't exist.
Error: No widgets deactivated.
"""
And the return code should be 1
When I try `wp widget deactivate text-1 calendar-999`
Then STDERR should be:
"""
Warning: Widget 'calendar-999' doesn't exist.
Error: Only deactivated 1 of 2 widgets.
"""
And the return code should be 1
Scenario: Return code is 1 when 1 or more widgets doesn't exist, deletion
When I try `wp widget delete calendar-999`
Then STDERR should be:
"""
Warning: Widget 'calendar-999' doesn't exist.
Error: No widgets deleted.
"""
And the return code should be 1
When I try `wp widget delete text-1 calendar-999`
Then STDERR should be:
"""
Warning: Widget 'calendar-999' doesn't exist.
Error: Only deleted 1 of 2 widgets.
"""
And the return code should be 1