Skip to content

Commit ad69fa6

Browse files
authored
Adapt tests to make the widget expectations more flexible (#34)
Adapt tests to make the widget expectations more flexible
2 parents 58a1b2d + caeffdf commit ad69fa6

2 files changed

Lines changed: 41 additions & 13 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"wp-cli/wp-cli": "^2"
15+
"wp-cli/wp-cli": "dev-master"
1616
},
1717
"require-dev": {
1818
"wp-cli/extension-command": "^1.2 || ^2",

features/widget-reset.feature

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ Feature: Reset WordPress sidebars
99
And the return code should be 0
1010

1111
When I run `wp widget list sidebar-1 --format=count`
12-
Then STDOUT should be:
13-
"""
14-
6
15-
"""
12+
# The count should be non-zero (= the sidebar contains widgets)
13+
Then STDOUT should match /^\s*[1-9][0-9]*\s*$/
1614

1715
When I run `wp widget reset sidebar-1`
1816
And I run `wp widget list sidebar-1 --format=count`
@@ -59,10 +57,8 @@ Feature: Reset WordPress sidebars
5957
Then STDOUT should not be empty
6058

6159
When I run `wp widget list sidebar-2 --format=count`
62-
Then STDOUT should be:
63-
"""
64-
1
65-
"""
60+
# The count should be non-zero (= the sidebar contains widgets)
61+
Then STDOUT should match /^\s*[1-9][0-9]*\s*$/
6662

6763
When I try `wp widget reset sidebar-1 sidebar-2 non-existing-sidebar-id`
6864
Then STDERR should be:
@@ -125,9 +121,41 @@ Feature: Reset WordPress sidebars
125121
0
126122
"""
127123
When I run `wp widget list wp_inactive_widgets --format=ids`
128-
Then STDOUT should be:
124+
Then STDOUT should contain:
125+
"""
126+
text-1
127+
"""
128+
Then STDOUT should contain:
129+
"""
130+
search-3
131+
"""
132+
Then STDOUT should contain:
133+
"""
134+
meta-2
129135
"""
130-
text-1 search-3 meta-2 categories-2 archives-2 recent-comments-2 recent-posts-2 search-2 calendar-1
136+
Then STDOUT should contain:
137+
"""
138+
categories-2
139+
"""
140+
Then STDOUT should contain:
141+
"""
142+
archives-2
143+
"""
144+
Then STDOUT should contain:
145+
"""
146+
recent-comments-2
147+
"""
148+
Then STDOUT should contain:
149+
"""
150+
recent-posts-2
151+
"""
152+
Then STDOUT should contain:
153+
"""
154+
search-2
155+
"""
156+
Then STDOUT should contain:
157+
"""
158+
calendar-1
131159
"""
132160

133161
Scenario: Testing movement of widgets while reset
@@ -144,7 +172,7 @@ Feature: Reset WordPress sidebars
144172
Then STDOUT should not be empty
145173

146174
When I run `wp widget list sidebar-2 --format=ids`
147-
Then STDOUT should be:
175+
Then STDOUT should contain:
148176
"""
149177
search-3 calendar-1
150178
"""
@@ -155,7 +183,7 @@ Feature: Reset WordPress sidebars
155183
And I run `wp widget list sidebar-2 --format=ids`
156184
Then STDOUT should be empty
157185
And I run `wp widget list wp_inactive_widgets --format=ids`
158-
Then STDOUT should be:
186+
Then STDOUT should contain:
159187
"""
160188
calendar-1 search-3
161189
"""

0 commit comments

Comments
 (0)