Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions features/post-term.feature
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,27 @@ Feature: Manage post term
| term_id | name | slug |
| 3 | 4 | 4 |

Scenario: Remove a term that is not assigned to the post
Given a WP install

When I run `wp post term add 1 post_tag apple`
And I run `wp term create post_tag banana`
Then STDOUT should not be empty

When I try `wp post term remove 1 post_tag banana`
Then STDERR should be:
"""
Error: Failed to remove term.
"""
And STDOUT should be empty
And the return code should be 1

When I run `wp post term list 1 post_tag --field=slug`
Then STDOUT should be:
"""
apple
"""

Scenario: Remove all terms from post
Given a WP install

Expand Down
2 changes: 1 addition & 1 deletion src/WP_CLI/CommandWithTerms.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function remove( $args, $assoc_args ) {

$label = count( $terms ) > 1 ? 'terms' : 'term';

if ( is_wp_error( $result ) ) {
if ( ! $result || is_wp_error( $result ) ) {
WP_CLI::error( "Failed to remove {$label}." );
}

Expand Down
Loading