@@ -156,22 +156,31 @@ Feature: Manage WordPress comments
156156 Given I run `wp comment create --comment_post_ID=1 --comment_approved=0 --porcelain`
157157 And save STDOUT as {COMMENT_ID}
158158
159+ # With site url set.
159160 When I run `wp comment approve {COMMENT_ID} --url=www.example.com`
160- Then STDOUT should contain :
161+ Then STDOUT should be :
161162 """
162- Approved comment {COMMENT_ID}
163+ Success: Approved comment {COMMENT_ID}.
163164 """
164165
166+ When I try the previous command again
167+ Then STDERR should be:
168+ """
169+ Error: Could not update comment status
170+ """
171+ And STDOUT should be empty
172+ And the return code should be 1
173+
165174 When I run `wp comment get --field=comment_approved {COMMENT_ID}`
166175 Then STDOUT should be:
167176 """
168177 1
169178 """
170179
171180 When I run `wp comment unapprove {COMMENT_ID} --url=www.example.com`
172- Then STDOUT should contain :
181+ Then STDOUT should be :
173182 """
174- Unapproved comment {COMMENT_ID}
183+ Success: Unapproved comment {COMMENT_ID}.
175184 """
176185
177186 When I run `wp comment get --field=comment_approved {COMMENT_ID}`
@@ -180,50 +189,40 @@ Feature: Manage WordPress comments
180189 0
181190 """
182191
192+ # Without site url set.
183193 When I try `wp comment approve {COMMENT_ID}`
184- Then STDOUT should contain :
194+ Then STDOUT should be :
185195 """
186- Approved comment {COMMENT_ID}
196+ Success: Approved comment {COMMENT_ID}.
187197 """
188- And STDERR should contain :
198+ And STDERR should be :
189199 """
190- Warning: `$_SERVER['SERVER_NAME']` not set. Setting to 'example.com'. Notification email sent to post author may appear to come from 'example.com'.
200+ Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
191201 """
192202 And the return code should be 0
193203
194- When I run `wp comment get --field=comment_approved {COMMENT_ID}`
195- Then STDOUT should be:
196- """
197- 1
198- """
199-
200204 When I try `wp comment unapprove {COMMENT_ID}`
201- Then STDOUT should contain :
205+ Then STDOUT should be :
202206 """
203- Unapproved comment {COMMENT_ID}
207+ Success: Unapproved comment {COMMENT_ID}.
204208 """
205- And STDERR should contain :
209+ And STDERR should be :
206210 """
207- Warning: `$_SERVER['SERVER_NAME']` not set. Setting to 'example.com'. Notification email sent to post author may appear to come from 'example.com'.
211+ Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
208212 """
209213 And the return code should be 0
210214
211- When I run `wp comment get --field=comment_approved {COMMENT_ID}`
212- Then STDOUT should be:
213- """
214- 0
215- """
216-
217215 Scenario : Approving/unapproving comments with multidigit comment ID
218216 Given I run `wp comment delete $(wp comment list --field=ID)`
219217 And I run `wp comment generate --count=10 --quiet`
220- And I run `wp comment create --porcelain`
218+ And I run `wp comment create --comment_post_ID=1 -- porcelain`
221219 And save STDOUT as {COMMENT_ID}
222220
221+ # With site url set.
223222 When I run `wp comment unapprove {COMMENT_ID} --url=www.example.com`
224- Then STDOUT should contain :
223+ Then STDOUT should be :
225224 """
226- Unapproved comment {COMMENT_ID}
225+ Success: Unapproved comment {COMMENT_ID}.
227226 """
228227
229228 When I run `wp comment list --format=count --status=approve`
@@ -233,9 +232,9 @@ Feature: Manage WordPress comments
233232 """
234233
235234 When I run `wp comment approve {COMMENT_ID} --url=www.example.com`
236- Then STDOUT should contain :
235+ Then STDOUT should be :
237236 """
238- Approved comment {COMMENT_ID}
237+ Success: Approved comment {COMMENT_ID}.
239238 """
240239
241240 When I run `wp comment list --format=count --status=approve`
@@ -244,16 +243,40 @@ Feature: Manage WordPress comments
244243 11
245244 """
246245
246+ # Without site url set.
247+ When I try `wp comment unapprove {COMMENT_ID}`
248+ Then STDOUT should be:
249+ """
250+ Success: Unapproved comment {COMMENT_ID}.
251+ """
252+ And STDERR should be:
253+ """
254+ Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
255+ """
256+ And the return code should be 0
257+
258+ When I try `wp comment approve {COMMENT_ID}`
259+ Then STDOUT should be:
260+ """
261+ Success: Approved comment {COMMENT_ID}.
262+ """
263+ And STDERR should be:
264+ """
265+ Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
266+ """
267+ And the return code should be 0
268+
247269 Scenario : Spam/unspam comments with multidigit comment ID
248270 Given I run `wp comment delete $(wp comment list --field=ID)`
249271 And I run `wp comment generate --count=10 --quiet`
250- And I run `wp comment create --porcelain`
272+ And I run `wp comment create --comment_post_ID=1 -- porcelain`
251273 And save STDOUT as {COMMENT_ID}
252274
275+ # With site url set.
253276 When I run `wp comment spam {COMMENT_ID}`
254- Then STDOUT should contain :
277+ Then STDOUT should be :
255278 """
256- Marked as spam comment {COMMENT_ID}.
279+ Success: Marked as spam comment {COMMENT_ID}.
257280 """
258281
259282 When I run `wp comment list --format=count --status=spam`
@@ -262,10 +285,10 @@ Feature: Manage WordPress comments
262285 1
263286 """
264287
265- When I run `wp comment unspam {COMMENT_ID}`
266- Then STDOUT should contain :
288+ When I run `wp comment unspam {COMMENT_ID} --url=www.example.com `
289+ Then STDOUT should be :
267290 """
268- Unspammed comment {COMMENT_ID}.
291+ Success: Unspammed comment {COMMENT_ID}.
269292 """
270293
271294 When I run `wp comment list --format=count --status=spam`
@@ -274,14 +297,33 @@ Feature: Manage WordPress comments
274297 0
275298 """
276299
300+ # Without site url set.
301+ When I run `wp comment spam {COMMENT_ID}`
302+ Then STDOUT should be:
303+ """
304+ Success: Marked as spam comment {COMMENT_ID}.
305+ """
306+
307+ When I try `wp comment unspam {COMMENT_ID}`
308+ Then STDOUT should be:
309+ """
310+ Success: Unspammed comment {COMMENT_ID}.
311+ """
312+ And STDERR should be:
313+ """
314+ Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
315+ """
316+ And the return code should be 0
317+
277318 Scenario : Trash/untrash comments with multidigit comment ID
278319 Given I run `wp comment delete $(wp comment list --field=ID) --force`
279320 And I run `wp comment generate --count=10 --quiet`
280- And I run `wp comment create --porcelain`
321+ And I run `wp comment create --comment_post_ID=1 -- porcelain`
281322 And save STDOUT as {COMMENT_ID}
282323
324+ # With site url set.
283325 When I run `wp comment trash {COMMENT_ID}`
284- Then STDOUT should contain :
326+ Then STDOUT should be :
285327 """
286328 Success: Trashed comment {COMMENT_ID}.
287329 """
@@ -292,10 +334,10 @@ Feature: Manage WordPress comments
292334 1
293335 """
294336
295- When I run `wp comment untrash {COMMENT_ID}`
296- Then STDOUT should contain :
337+ When I run `wp comment untrash {COMMENT_ID} --url=www.example.com `
338+ Then STDOUT should be :
297339 """
298- Untrashed comment {COMMENT_ID}.
340+ Success: Untrashed comment {COMMENT_ID}.
299341 """
300342
301343 When I run `wp comment list --format=count --status=trash`
@@ -304,6 +346,24 @@ Feature: Manage WordPress comments
304346 0
305347 """
306348
349+ # Without site url set.
350+ When I run `wp comment trash {COMMENT_ID}`
351+ Then STDOUT should be:
352+ """
353+ Success: Trashed comment {COMMENT_ID}.
354+ """
355+
356+ When I try `wp comment untrash {COMMENT_ID}`
357+ Then STDOUT should be:
358+ """
359+ Success: Untrashed comment {COMMENT_ID}.
360+ """
361+ And STDERR should be:
362+ """
363+ Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
364+ """
365+ And the return code should be 0
366+
307367 Scenario : Make sure WordPress receives the slashed data it expects
308368 When I run `wp comment create --comment_content='My\C omment' --porcelain`
309369 Then save STDOUT as {COMMENT_ID}
@@ -322,3 +382,16 @@ Feature: Manage WordPress comments
322382 """
323383 My\New\Comment
324384 """
385+
386+ @require-wp-4.4
387+ Scenario : Approving/unapproving/unspamming/untrashing (approved) comments with no comment post id should not produce PHP notices for WP >= 4.4
388+ Given I run `wp comment create --comment_approved=0 --porcelain`
389+ And save STDOUT as {COMMENT_ID}
390+ When I run `wp comment approve {COMMENT_ID} --url=www.example.com`
391+ And I run `wp comment unapprove {COMMENT_ID} --url=www.example.com`
392+
393+ Given I run `wp comment approve {COMMENT_ID} --url=www.example.com`
394+ When I run `wp comment spam {COMMENT_ID} --url=www.example.com`
395+ And I run `wp comment unspam {COMMENT_ID} --url=www.example.com`
396+ And I run `wp comment trash {COMMENT_ID} --url=www.example.com`
397+ And I run `wp comment untrash {COMMENT_ID} --url=www.example.com`
0 commit comments