Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions features/comment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,62 @@ Feature: Manage WordPress comments
11
"""

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 --porcelain`
And save STDOUT as {COMMENT_ID}

When I run `wp comment spam {COMMENT_ID}`
Then STDOUT should contain:
"""
Marked as spam comment {COMMENT_ID}.
"""

When I run `wp comment list --format=count --status=spam`
Then STDOUT should be:
"""
1
"""

When I run `wp comment unspam {COMMENT_ID}`
Then STDOUT should contain:
"""
Unspammed comment {COMMENT_ID}.
"""

When I run `wp comment list --format=count --status=spam`
Then STDOUT 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 --porcelain`
And save STDOUT as {COMMENT_ID}

When I run `wp comment trash {COMMENT_ID}`
Then STDOUT should contain:
"""
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}`
Then STDOUT should contain:
"""
Untrashed comment {COMMENT_ID}.
"""

When I run `wp comment list --format=count --status=trash`
Then STDOUT should be:
"""
0
"""
4 changes: 2 additions & 2 deletions php/commands/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public function delete( $args, $assoc_args ) {
}

private function call( $args, $status, $success, $failure ) {
list( $comment_id ) = $args;
$comment_id = absint( $args );

$func = sprintf( 'wp_%s_comment', $status );

Expand Down Expand Up @@ -395,7 +395,7 @@ public function spam( $args, $assoc_args ) {
*/
public function unspam( $args, $assoc_args ) {
foreach( $args as $id ) {
$this->call( $args, __FUNCTION__, 'Unspammed', 'Failed unspamming' );
$this->call( $id, __FUNCTION__, 'Unspammed', 'Failed unspamming' );
}
}

Expand Down