diff --git a/features/menu-item.feature b/features/menu-item.feature index 494e0dfd0..c5a040568 100644 --- a/features/menu-item.feature +++ b/features/menu-item.feature @@ -252,3 +252,27 @@ Feature: Manage WordPress menu items """ And the return code should be 1 + Scenario: Add a post type archive as a menu item + + When I run `wp menu create "Archive Menu"` + Then STDOUT should not be empty + + When I run `wp menu item add-post-type-archive archive-menu post --porcelain` + Then STDOUT should be a number + And save STDOUT as {ITEM_ID} + + When I run `wp menu item list archive-menu --fields=db_id,type,object` + Then STDOUT should be a table containing rows: + | db_id | type | object | + | {ITEM_ID} | post_type_archive | post | + + When I run `wp menu item get {ITEM_ID} --field=link` + Then STDOUT should not be empty + + When I try `wp menu item add-post-type-archive archive-menu invalidposttype` + Then STDERR should be: + """ + Error: Invalid post type. + """ + And the return code should be 1 + diff --git a/src/Menu_Item_Command.php b/src/Menu_Item_Command.php index 40bf6610b..94a1ea3f3 100644 --- a/src/Menu_Item_Command.php +++ b/src/Menu_Item_Command.php @@ -329,6 +329,69 @@ public function add_term( $args, $assoc_args ) { $this->add_or_update_item( 'add', 'taxonomy', $args, $assoc_args ); } + /** + * Adds a post type archive as a menu item. + * + * ## OPTIONS + * + *