From 64a764b0639d715454d1ede741ab9f38bb588e6b Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Sat, 28 May 2016 08:00:45 +0545 Subject: [PATCH 1/3] fix comment id issue in spam and unspam --- php/commands/comment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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' ); } } From b473ca695beea373a82e961e76f39c1090b7de32 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Sat, 28 May 2016 08:04:39 +0545 Subject: [PATCH 2/3] add test for comment spam/unspam --- features/comment.feature | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/features/comment.feature b/features/comment.feature index ef11b422ce..12a28912da 100644 --- a/features/comment.feature +++ b/features/comment.feature @@ -190,3 +190,32 @@ 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 + """ From 2512afdf71416d6810093fe25d6f29335f0d64b3 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Sat, 28 May 2016 08:21:11 +0545 Subject: [PATCH 3/3] add test for comment trash/unstrash with multidigit comment ID --- features/comment.feature | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/features/comment.feature b/features/comment.feature index 12a28912da..0eaacc0048 100644 --- a/features/comment.feature +++ b/features/comment.feature @@ -219,3 +219,33 @@ Feature: Manage WordPress comments """ 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 + """