File tree Expand file tree Collapse file tree 2 files changed +9
-18
lines changed
Expand file tree Collapse file tree 2 files changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -47,23 +47,13 @@ Feature: Manage WordPress posts
4747 When I try `wp post update {POST_ID} --post_category=test`
4848 Then STDERR should be:
4949 """
50- Warning: Unable to set test as post category
51- """
52- And STDOUT should be:
53- """
54- Success: Updated post {POST_ID}.
50+ Error: No such post category 'test'.
5551 """
5652
5753 When I try `wp post create --post_title="Test category two" --post_category={SECOND_TERM_ID},Test --porcelain`
58- Then STDOUT should be a number
59- And save STDOUT as {POST_ID_TWO}
6054 Then STDERR should be:
6155 """
62- Warning: Unable to set Test as post category
63- """
64- And STDOUT should be:
65- """
66- {POST_ID_TWO}
56+ Error: No such post category 'Test'.
6757 """
6858
6959 Scenario : Creating/getting/editing posts
Original file line number Diff line number Diff line change @@ -760,13 +760,14 @@ private function get_category_ids( $arg ) {
760760
761761 foreach ( $ categoires as $ post_category ) {
762762 if ( trim ( $ post_category ) !== '' ) {
763- $ post_category = ( true === is_numeric ( $ post_category ) ) ? intval ( $ post_category ) : $ post_category ;
764-
765- $ category_id = category_exists ( $ post_category );
766-
767- if ( null === $ category_id ) {
763+ if ( is_numeric ( $ post_category ) && (int ) $ post_category ) {
764+ $ category_id = category_exists ( (int ) $ post_category );
765+ } else {
766+ $ category_id = category_exists ( $ post_category );
767+ }
768+ if ( ! $ category_id ) {
768769 $ category_ids [] = $ post_category ;
769- WP_CLI ::warning ( "Unable to set $ post_category as post category " );
770+ WP_CLI ::error ( "No such post category ' $ post_category '. " );
770771 } else {
771772 $ category_ids [] = $ category_id ;
772773 }
You can’t perform that action at this time.
0 commit comments