Repository navigation
Expand file tree
/
Copy pathcli.feature
More file actions
282 lines (244 loc) 路 7.18 KB
/
Copy pathcli.feature
File metadata and controls
282 lines (244 loc) 路 7.18 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
Feature: `wp cli` tasks
Scenario: Ability to set a custom version when building
Given an empty directory
And save the {FRAMEWORK_ROOT}/VERSION file as {TRUE_VERSION}
And a new Phar with version "1.2.3"
When I run `{PHAR_PATH} cli version`
Then STDOUT should be:
"""
WP-CLI 1.2.3
"""
And the {FRAMEWORK_ROOT}/VERSION file should be:
"""
{TRUE_VERSION}
"""
@github-api
Scenario: Check for updates
Given an empty directory
And a new Phar with version "0.0.0"
When I run `{PHAR_PATH} cli check-update`
Then STDOUT should contain:
"""
package_url
"""
And STDERR should be empty
@github-api
Scenario: Do WP-CLI Update
Given an empty directory
And a new Phar with version "0.0.0"
When I run `{PHAR_PATH} --info`
Then STDOUT should contain:
"""
WP-CLI version
"""
And STDOUT should contain:
"""
0.0.0
"""
When I run `{PHAR_PATH} cli update --yes`
Then STDOUT should contain:
"""
sha512 hash verified:
"""
And STDOUT should contain:
"""
Success:
"""
And STDERR should be empty
And the return code should be 0
When I run `{PHAR_PATH} --info`
Then STDOUT should contain:
"""
WP-CLI version
"""
And STDOUT should not contain:
"""
0.0.0
"""
When I run `{PHAR_PATH} cli update`
Then STDOUT should be:
"""
Success: WP-CLI is at the latest version.
"""
@github-api
Scenario: Patch update from 2.8.0 to 2.8.1
Given an empty directory
And a new Phar with version "2.8.0"
When I run `{PHAR_PATH} --version`
Then STDOUT should be:
"""
WP-CLI 2.8.0
"""
When I run `{PHAR_PATH} cli update --patch --yes`
Then STDOUT should contain:
"""
sha512 hash verified: c1d40ee90b330ca1f8ddbed14b938b41ec5d9ff723c7c1cf3f41a2d9a1b271079a51a37ea3d1c9aa9c628fdd43449dba3995a8de150a68abbd505b06b91d9d2b
"""
And STDOUT should contain:
"""
Success: Updated WP-CLI to 2.8.1
"""
And STDERR should be empty
And the return code should be 0
When I run `{PHAR_PATH} --version`
Then STDOUT should be:
"""
WP-CLI 2.8.1
"""
@github-api
Scenario: Not a patch update from 2.8.0
Given an empty directory
And a new Phar with version "2.8.0"
When I run `{PHAR_PATH} cli update --no-patch --yes`
Then STDOUT should contain:
"""
Success:
"""
And STDOUT should not contain:
"""
2.8.1
"""
And STDERR should be empty
And the return code should be 0
Scenario: Install WP-CLI nightly
Given an empty directory
And a new Phar with version "2.8.0"
When I run `{PHAR_PATH} cli update --nightly --yes`
Then STDOUT should contain:
"""
sha512 hash verified:
"""
And STDOUT should contain:
"""
Success: Updated WP-CLI to the latest nightly release.
"""
And STDERR should be empty
And the return code should be 0
@github-api
Scenario: Install WP-CLI stable
Given an empty directory
And a new Phar with version "2.8.0"
And a session file:
"""
y
"""
When I run `{PHAR_PATH} cli check-update --field=version | head -1`
Then STDOUT should not be empty
And save STDOUT as {UPDATE_VERSION}
When I run `{PHAR_PATH} cli update --stable < session`
Then STDOUT should contain:
"""
You are currently using WP-CLI version 2.8.0. Would you like to update to the latest stable release? [y/n]
"""
And STDOUT should contain:
"""
sha512 hash verified:
"""
And STDOUT should contain:
"""
Success: Updated WP-CLI to the latest stable release.
"""
And STDERR should be empty
And the return code should be 0
When I run `{PHAR_PATH} cli check-update`
Then STDOUT should be:
"""
Success: WP-CLI is at the latest version.
"""
When I run `{PHAR_PATH} cli version`
Then STDOUT should be:
"""
WP-CLI {UPDATE_VERSION}
"""
Scenario: Fail update when sha512 hash cannot be accessed
Given an empty directory
And a new Phar with version "2.8.0"
And that HTTP requests to https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar.sha512 will respond with:
"""
HTTP/1.1 404 Not Found
Content-Type: text/plain
Not Found
"""
When I try `{PHAR_PATH} cli update --nightly --yes`
Then STDERR should contain:
"""
Error: Couldn't access sha512 hash for release (HTTP code 404).
"""
And the return code should be 1
Scenario: Fail update when sha512 hash mismatches
Given an empty directory
And a new Phar with version "2.8.0"
And that HTTP requests to https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar.sha512 will respond with:
"""
HTTP/1.1 200 OK
Content-Type: text/plain
invalidsha512hash
"""
When I try `{PHAR_PATH} cli update --nightly --yes`
Then STDERR should contain:
"""
Error: sha512 hash for download
"""
And STDERR should contain:
"""
is different than the release hash (invalidsha512hash).
"""
And the return code should be 1
Scenario: Update only verifies the sha512 hash
Given an empty directory
And a new Phar with version "2.8.0"
And that HTTP requests to https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar.md5 will respond with:
"""
HTTP/1.1 200 OK
Content-Type: text/plain
invalidmd5hash
"""
When I run `{PHAR_PATH} cli update --nightly --yes`
Then STDOUT should contain:
"""
sha512 hash verified:
"""
And STDOUT should not contain:
"""
md5
"""
And STDOUT should contain:
"""
Success: Updated WP-CLI to the latest nightly release.
"""
And STDERR should be empty
And the return code should be 0
Scenario: Prevent stable update when PHP version requirement is not met
Given an empty directory
And a new Phar with version "2.8.0"
And that HTTP requests to https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.manifest.json will respond with:
"""
HTTP/1.1 200
Content-Type: application/json
{
"requires_php": "99.0.0"
}
"""
When I try `{PHAR_PATH} cli update --stable --yes`
Then STDERR should contain:
"""
The requested update requires PHP 99.0.0 or higher.
"""
And the return code should be 1
Scenario: Prevent nightly update when PHP version requirement is not met
Given an empty directory
And a new Phar with version "2.8.0"
And that HTTP requests to https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.manifest.json will respond with:
"""
HTTP/1.1 200
Content-Type: application/json
{
"requires_php": "99.0.0"
}
"""
When I try `{PHAR_PATH} cli update --nightly --yes`
Then STDERR should contain:
"""
The requested update requires PHP 99.0.0 or higher.
"""
And the return code should be 1