diff --git a/features/post.feature b/features/post.feature index 858668bf..1988cce5 100644 --- a/features/post.feature +++ b/features/post.feature @@ -57,6 +57,23 @@ Feature: Manage WordPress posts When I try the previous command again Then the return code should be 1 + Scenario: Deleting already trashed custom post type posts + When I run `wp post create --post_title='Test CPT post' --post_type='book' --porcelain` + Then STDOUT should be a number + And save STDOUT as {BOOK_POST_ID} + + When I run `wp post update {BOOK_POST_ID} --post_status='trash'` + Then STDOUT should be: + """ + Success: Updated post {BOOK_POST_ID}. + """ + + When I run `wp post delete {BOOK_POST_ID}` + Then STDOUT should be: + """ + Success: Deleted post {BOOK_POST_ID}. + """ + Scenario: Updating an invalid post should exit with an error Given a WP install diff --git a/src/Post_Command.php b/src/Post_Command.php index b8dd833d..05c5af1b 100644 --- a/src/Post_Command.php +++ b/src/Post_Command.php @@ -497,6 +497,7 @@ protected function delete_callback( $post_id, $assoc_args ) { $post_type = get_post_type( $post_id ); if ( ! $assoc_args['force'] + && 'trash' !== $status && ( 'post' !== $post_type && 'page' !== $post_type ) ) { return [ 'error',