-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathcomment.feature
More file actions
474 lines (405 loc) · 13.2 KB
/
comment.feature
File metadata and controls
474 lines (405 loc) · 13.2 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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
Feature: Manage WordPress comments
Background:
Given a WP install
Scenario: Creating/updating/deleting comments
When I run `wp comment create --comment_post_ID=1 --comment_content='Hello' --comment_author='Billy' --porcelain`
Then STDOUT should be a number
And save STDOUT as {COMMENT_ID}
When I run `wp comment exists {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Comment with ID {COMMENT_ID} exists.
"""
When I run `wp comment update {COMMENT_ID} --comment_author='Johnny'`
Then STDOUT should not be empty
When I run `wp comment get {COMMENT_ID} --field=author`
Then STDOUT should be:
"""
Johnny
"""
When I run `wp comment delete {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Trashed comment {COMMENT_ID}.
"""
When I run `wp comment get {COMMENT_ID} --field=comment_approved`
Then STDOUT should be:
"""
trash
"""
When I run `wp comment delete {COMMENT_ID} --force`
Then STDOUT should be:
"""
Success: Deleted comment {COMMENT_ID}.
"""
When I try `wp comment get {COMMENT_ID}`
Then STDERR should be:
"""
Error: Invalid comment ID.
"""
And the return code should be 1
When I run `wp comment create --comment_post_ID=1`
And I run `wp comment create --comment_post_ID=1`
And I run `wp comment delete 3 4`
Then STDOUT should be:
"""
Success: Trashed comment 3.
Success: Trashed comment 4.
"""
When I run `wp comment delete 3`
Then STDOUT should be:
"""
Success: Deleted comment 3.
"""
When I try `wp comment get 3`
Then STDERR should be:
"""
Error: Invalid comment ID.
"""
And the return code should be 1
Scenario: Updating an invalid comment should return an error
Given a WP install
When I try `wp comment update 22 --comment_author=Foo`
Then the return code should be 1
And STDERR should contain:
"""
Warning: Could not update comment.
"""
Scenario: Get details about an existing comment
When I run `wp comment get 1`
Then STDOUT should be a table containing rows:
| Field | Value |
| comment_approved | 1 |
When I run `wp comment get 1 --fields=comment_approved --format=json`
Then STDOUT should be JSON containing:
"""
{"comment_approved":"1"}
"""
When I run `wp comment list --fields=comment_approved`
Then STDOUT should be a table containing rows:
| comment_approved |
| 1 |
When I run `wp comment list --field=approved`
Then STDOUT should be:
"""
1
"""
When I run `wp comment list --format=ids`
Then STDOUT should be:
"""
1
"""
When I run `wp comment url 1`
Then STDOUT should contain:
"""
#comment-1
"""
When I run `wp comment get 1 --field=url`
Then STDOUT should contain:
"""
#comment-1
"""
Scenario: List the URLs of comments
When I run `wp comment create --comment_post_ID=1 --porcelain`
Then save STDOUT as {COMMENT_ID}
When I run `wp comment url 1 {COMMENT_ID}`
Then STDOUT should be:
"""
https://example.com/?p=1#comment-1
https://example.com/?p=1#comment-{COMMENT_ID}
"""
When I run `wp comment url {COMMENT_ID} 1`
Then STDOUT should be:
"""
https://example.com/?p=1#comment-{COMMENT_ID}
https://example.com/?p=1#comment-1
"""
Scenario: Count comments
When I run `wp comment count 1`
Then STDOUT should contain:
"""
approved: 1
"""
And STDOUT should contain:
"""
moderated: 0
"""
And STDOUT should contain:
"""
total_comments: 1
"""
When I run `wp comment count`
Then STDOUT should contain:
"""
approved: 1
"""
And STDOUT should contain:
"""
moderated: 0
"""
And STDOUT should contain:
"""
total_comments: 1
"""
@require-mysql
Scenario: Approving/unapproving comments
Given I run `wp comment create --comment_post_ID=1 --comment_approved=0 --porcelain`
And save STDOUT as {COMMENT_ID}
# With site url set.
When I run `wp comment approve {COMMENT_ID} --url=www.example.com`
Then STDOUT should be:
"""
Success: Approved comment {COMMENT_ID}.
"""
When I try the previous command again
Then STDERR should contain:
"""
Error: Could not update comment status
"""
And STDOUT should be empty
And the return code should be 1
When I run `wp comment get --field=comment_approved {COMMENT_ID}`
Then STDOUT should be:
"""
1
"""
When I run `wp comment unapprove {COMMENT_ID} --url=www.example.com`
Then STDOUT should be:
"""
Success: Unapproved comment {COMMENT_ID}.
"""
When I run `wp comment get --field=comment_approved {COMMENT_ID}`
Then STDOUT should be:
"""
0
"""
# Without site url set.
When I try `wp comment approve {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Approved comment {COMMENT_ID}.
"""
And STDERR should be:
"""
Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
"""
And the return code should be 0
When I try `wp comment unapprove {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Unapproved comment {COMMENT_ID}.
"""
And STDERR should be:
"""
Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
"""
And the return code should be 0
# Approving an approved comment works in SQLite
@require-sqlite
Scenario: Approving/unapproving comments
Given I run `wp comment create --comment_post_ID=1 --comment_approved=0 --porcelain`
And save STDOUT as {COMMENT_ID}
# With site url set.
When I run `wp comment approve {COMMENT_ID} --url=www.example.com`
Then STDOUT should be:
"""
Success: Approved comment {COMMENT_ID}.
"""
When I try the previous command again
Then STDOUT should be:
"""
Success: Approved comment {COMMENT_ID}.
"""
When I run `wp comment get --field=comment_approved {COMMENT_ID}`
Then STDOUT should be:
"""
1
"""
When I run `wp comment unapprove {COMMENT_ID} --url=www.example.com`
Then STDOUT should be:
"""
Success: Unapproved comment {COMMENT_ID}.
"""
When I run `wp comment get --field=comment_approved {COMMENT_ID}`
Then STDOUT should be:
"""
0
"""
# Without site url set.
When I try `wp comment approve {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Approved comment {COMMENT_ID}.
"""
And STDERR should be:
"""
Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
"""
And the return code should be 0
When I try `wp comment unapprove {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Unapproved comment {COMMENT_ID}.
"""
And STDERR should be:
"""
Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
"""
And the return code should be 0
Scenario: Approving/unapproving comments with multidigit comment ID
Given I run `wp comment delete $(wp comment list --field=ID)`
And I run `wp comment generate --count=10 --quiet`
And I run `wp comment create --comment_post_ID=1 --porcelain`
And save STDOUT as {COMMENT_ID}
# With site url set.
When I run `wp comment unapprove {COMMENT_ID} --url=www.example.com`
Then STDOUT should be:
"""
Success: Unapproved comment {COMMENT_ID}.
"""
When I run `wp comment list --format=count --status=approve`
Then STDOUT should be:
"""
10
"""
When I run `wp comment approve {COMMENT_ID} --url=www.example.com`
Then STDOUT should be:
"""
Success: Approved comment {COMMENT_ID}.
"""
When I run `wp comment list --format=count --status=approve`
Then STDOUT should be:
"""
11
"""
# Without site url set.
When I try `wp comment unapprove {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Unapproved comment {COMMENT_ID}.
"""
And STDERR should be:
"""
Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
"""
And the return code should be 0
When I try `wp comment approve {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Approved comment {COMMENT_ID}.
"""
And STDERR should be:
"""
Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
"""
And the return code should be 0
Scenario: Spam/unspam comments with multidigit comment ID
Given I run `wp comment delete $(wp comment list --field=ID)`
And I run `wp comment generate --count=10 --quiet`
And I run `wp comment create --comment_post_ID=1 --porcelain`
And save STDOUT as {COMMENT_ID}
# With site url set.
When I run `wp comment spam {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Marked comment {COMMENT_ID} as spam.
"""
When I run `wp comment list --format=count --status=spam`
Then STDOUT should be:
"""
1
"""
When I run `wp comment unspam {COMMENT_ID} --url=www.example.com`
Then STDOUT should be:
"""
Success: Unspammed comment {COMMENT_ID}.
"""
When I run `wp comment list --format=count --status=spam`
Then STDOUT should be:
"""
0
"""
# Without site url set.
When I run `wp comment spam {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Marked comment {COMMENT_ID} as spam.
"""
When I try `wp comment unspam {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Unspammed comment {COMMENT_ID}.
"""
And STDERR should be:
"""
Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
"""
And the return code should be 0
Scenario: Trash/untrash comments with multidigit comment ID
Given I run `wp comment delete $(wp comment list --field=ID) --force`
And I run `wp comment generate --count=10 --quiet`
And I run `wp comment create --comment_post_ID=1 --porcelain`
And save STDOUT as {COMMENT_ID}
# With site url set.
When I run `wp comment trash {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Trashed comment {COMMENT_ID}.
"""
When I run `wp comment list --format=count --status=trash`
Then STDOUT should be:
"""
1
"""
When I run `wp comment untrash {COMMENT_ID} --url=www.example.com`
Then STDOUT should be:
"""
Success: Untrashed comment {COMMENT_ID}.
"""
When I run `wp comment list --format=count --status=trash`
Then STDOUT should be:
"""
0
"""
# Without site url set.
When I run `wp comment trash {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Trashed comment {COMMENT_ID}.
"""
When I try `wp comment untrash {COMMENT_ID}`
Then STDOUT should be:
"""
Success: Untrashed comment {COMMENT_ID}.
"""
And STDERR should be:
"""
Warning: Site url not set - defaulting to 'example.com'. Any notification emails sent to post author may appear to come from 'example.com'.
"""
And the return code should be 0
Scenario: Make sure WordPress receives the slashed data it expects
When I run `wp comment create --comment_content='My\Comment' --porcelain`
Then save STDOUT as {COMMENT_ID}
When I run `wp comment get {COMMENT_ID} --field=comment_content`
Then STDOUT should be:
"""
My\Comment
"""
When I run `wp comment update {COMMENT_ID} --comment_content='My\New\Comment'`
Then STDOUT should not be empty
When I run `wp comment get {COMMENT_ID} --field=comment_content`
Then STDOUT should be:
"""
My\New\Comment
"""
@require-wp-4.4
Scenario: Approving/unapproving/unspamming/untrashing (approved) comments with no comment post id should not produce PHP notices for WP >= 4.4
Given I run `wp comment create --comment_approved=0 --porcelain`
And save STDOUT as {COMMENT_ID}
When I run `wp comment approve {COMMENT_ID} --url=www.example.com`
And I run `wp comment unapprove {COMMENT_ID} --url=www.example.com`
Given I run `wp comment approve {COMMENT_ID} --url=www.example.com`
When I run `wp comment spam {COMMENT_ID} --url=www.example.com`
And I run `wp comment unspam {COMMENT_ID} --url=www.example.com`
And I run `wp comment trash {COMMENT_ID} --url=www.example.com`
And I run `wp comment untrash {COMMENT_ID} --url=www.example.com`