Skip to content

Commit

Permalink
Added functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeshjangam committed Nov 10, 2023
1 parent dc21092 commit 4ab17b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions features/media-import.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ Feature: Manage WordPress attachments
Success: Imported 1 of 1 items.
"""

Scenario: Import media from remote URL and use input file as attachment name
When I run `wp media import 'http://wp-cli.org/behat-data/codeispoetry.png' --file_name=abc`
Then STDOUT should contain:
"""
file name abc.png
"""
And STDOUT should contain:
"""
Success: Imported 1 of 1 items.
"""

Scenario: Fail to import missing image
When I try `wp media import gobbledygook.png`
Then STDERR should be:
Expand Down
4 changes: 4 additions & 0 deletions src/Media_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,10 @@ public function import( $args, $assoc_args = array() ) {
}

$attachment_success_text = '';
if ( $assoc_args['file_name'] ) {
$attachment_success_text .= ", file name {$name}";
}

if ( $assoc_args['post_id'] ) {
$attachment_success_text = " and attached to post {$assoc_args['post_id']}";
if ( Utils\get_flag_value( $assoc_args, 'featured_image' ) ) {
Expand Down

0 comments on commit 4ab17b8

Please sign in to comment.