@@ -34,10 +34,10 @@ Feature: Manage WordPress menu items
3434 When I run `wp menu item add-term sidebar-menu post_tag {TERM_ID} --porcelain`
3535 Then save STDOUT as {TERM_ITEM_ID}
3636
37- When I run `wp menu item add-custom sidebar-menu Apple http ://apple.com --parent-id={POST_ITEM_ID} --porcelain`
37+ When I run `wp menu item add-custom sidebar-menu Apple https ://apple.com --parent-id={POST_ITEM_ID} --porcelain`
3838 Then save STDOUT as {CUSTOM_ITEM_ID}
3939
40- When I run `wp menu item update {CUSTOM_ITEM_ID} --title=WordPress --link='http ://wordpress.org' --target=_blank --position=2`
40+ When I run `wp menu item update {CUSTOM_ITEM_ID} --title=WordPress --link='https ://wordpress.org' --target=_blank --position=2`
4141 Then STDOUT should be:
4242 """
4343 Success: Menu item updated.
@@ -51,10 +51,10 @@ Feature: Manage WordPress menu items
5151
5252 When I run `wp menu item list sidebar-menu --fields=type,title,description,position,link,menu_item_parent`
5353 Then STDOUT should be a table containing rows:
54- | type | title | description | position | link | menu_item_parent |
55- | post_type | Custom Test Post | Washington Apples | 1 | {POST_LINK } | 0 |
56- | custom | WordPress | | 2 | http ://wordpress .org | {POST_ITEM_ID } |
57- | taxonomy | Test term | | 3 | {TERM_LINK } | 0 |
54+ | type | title | description | position | link | menu_item_parent |
55+ | post_type | Custom Test Post | Washington Apples | 1 | {POST_LINK } | 0 |
56+ | custom | WordPress | | 2 | https ://wordpress .org | {POST_ITEM_ID } |
57+ | taxonomy | Test term | | 3 | {TERM_LINK } | 0 |
5858
5959 When I run `wp menu item list sidebar-menu --format=ids`
6060 Then STDOUT should not be empty
@@ -122,7 +122,7 @@ Feature: Manage WordPress menu items
122122 """
123123 And the return code should be 1
124124
125- When I run `wp menu item add-custom sidebar-menu Apple http ://apple.com --porcelain`
125+ When I run `wp menu item add-custom sidebar-menu Apple https ://apple.com --porcelain`
126126 Then save STDOUT as {CUSTOM_ITEM_ID}
127127
128128 When I try `wp menu item delete {CUSTOM_ITEM_ID} 99999999`
@@ -132,3 +132,66 @@ Feature: Manage WordPress menu items
132132 Error: Only deleted 1 of 2 menu items.
133133 """
134134 And the return code should be 1
135+
136+ Scenario : Menu order is recalculated on insertion
137+ When I run `wp menu create "Sidebar Menu" `
138+ Then STDOUT should not be empty
139+
140+ When I run `wp menu item add-custom sidebar-menu First https://first.com --porcelain`
141+ Then save STDOUT as {ITEM_ID_1}
142+
143+ When I run `wp menu item add-custom sidebar-menu Second https://second.com --porcelain`
144+ Then save STDOUT as {ITEM_ID_2}
145+
146+ When I run `wp menu item add-custom sidebar-menu Third https://third.com --porcelain`
147+ Then save STDOUT as {ITEM_ID_3}
148+
149+ When I run `wp menu item list sidebar-menu --fields=type,title,position,link`
150+ Then STDOUT should be a table containing rows:
151+ | type | title | position | link |
152+ | custom | First | 1 | https ://first .com |
153+ | custom | Second | 2 | https ://second .com |
154+ | custom | Third | 3 | https ://third .com |
155+
156+ When I run `wp menu item add-custom sidebar-menu Fourth https://fourth.com --position=2 --porcelain`
157+ Then save STDOUT as {ITEM_ID_4}
158+
159+ When I run `wp menu item list sidebar-menu --fields=type,title,position,link`
160+ Then STDOUT should be a table containing rows:
161+ | type | title | position | link |
162+ | custom | First | 1 | https ://first .com |
163+ | custom | Fourth | 2 | https ://fourth .com |
164+ | custom | Second | 3 | https ://second .com |
165+ | custom | Third | 4 | https ://third .com |
166+
167+ Scenario : Menu order is recalculated on deletion
168+ When I run `wp menu create "Sidebar Menu" `
169+ Then STDOUT should not be empty
170+
171+ When I run `wp menu item add-custom sidebar-menu First https://first.com --porcelain`
172+ Then save STDOUT as {ITEM_ID_1}
173+
174+ When I run `wp menu item add-custom sidebar-menu Second https://second.com --porcelain`
175+ Then save STDOUT as {ITEM_ID_2}
176+
177+ When I run `wp menu item add-custom sidebar-menu Third https://third.com --porcelain`
178+ Then save STDOUT as {ITEM_ID_3}
179+
180+ When I run `wp menu item list sidebar-menu --fields=type,title,position,link`
181+ Then STDOUT should be a table containing rows:
182+ | type | title | position | link |
183+ | custom | First | 1 | https ://first .com |
184+ | custom | Second | 2 | https ://second .com |
185+ | custom | Third | 3 | https ://third .com |
186+
187+ When I run `wp menu item delete {ITEM_ID_2}`
188+ Then STDOUT should be:
189+ """
190+ Success: Deleted 1 of 1 menu items.
191+ """
192+
193+ When I run `wp menu item list sidebar-menu --fields=type,title,position,link`
194+ Then STDOUT should be a table containing rows:
195+ | type | title | position | link |
196+ | custom | First | 1 | https ://first .com |
197+ | custom | Third | 2 | https ://third .com |
0 commit comments