Skip to content

Commit 1637118

Browse files
Add test to check error case
1 parent bb9bb6c commit 1637118

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

features/post.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ Feature: Manage WordPress posts
267267
{POST_ID}
268268
"""
269269

270+
When I run `wp post url-to-id non-existent-url`
271+
Then STDOUT should contain:
272+
"""
273+
Could not get post with url 'non-existent-url'.
274+
"""
275+
270276
Scenario: Update a post from file or STDIN
271277
Given a content.html file:
272278
"""

src/Post_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ public function url_to_id( $args, $assoc_args ) {
897897
$post_id = url_to_postid( $args[0] );
898898

899899
if ( ! $value ) {
900-
WP_CLI::error( "Could not get post with url '{$args[0]}'." );
900+
WP_CLI::error( "Could not get post with url '$args[0]'." );
901901
}
902902

903903
WP_CLI::print_value( $post_id, $assoc_args );

0 commit comments

Comments
 (0)