-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathcomment-recount.feature
More file actions
38 lines (33 loc) · 1013 Bytes
/
comment-recount.feature
File metadata and controls
38 lines (33 loc) · 1013 Bytes
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
Feature: Recount comments on a post
Scenario: Recount comments on a post
Given a WP install
When I run `wp comment create --comment_post_ID=1 --comment_approved=1 --porcelain`
And I run `wp comment create --comment_post_ID=1 --comment_approved=1 --porcelain`
And I run `wp post get 1 --field=comment_count`
Then STDOUT should be:
"""
3
"""
Given a recount-comments.php file:
"""
<?php
global $wpdb;
$wpdb->update( $wpdb->posts, array( "comment_count" => 1 ), array( "ID" => 1 ) );
clean_post_cache( 1 );
"""
When I run `wp eval-file recount-comments.php`
And I run `wp post get 1 --field=comment_count`
Then STDOUT should be:
"""
1
"""
When I run `wp comment recount 1`
Then STDOUT should be:
"""
Updated post 1 comment count to 3.
"""
When I try `wp comment recount 99999999`
Then STDERR should be:
"""
Warning: Post 99999999 doesn't exist.
"""