diff --git a/features/comment.feature b/features/comment.feature index ef11b422ce..0eaacc0048 100644 --- a/features/comment.feature +++ b/features/comment.feature @@ -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 + """ diff --git a/php/commands/comment.php b/php/commands/comment.php index 34a912cc77..47891656e9 100644 --- a/php/commands/comment.php +++ b/php/commands/comment.php @@ -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 ); @@ -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' ); } }