@@ -180,4 +180,82 @@ function test_orderby_name_by_default() {
180
180
181
181
$ this ->assertEquals ( $ nav_menus_names , $ expected_nav_menus_names );
182
182
}
183
+
184
+ /**
185
+ * @ticket 35324
186
+ */
187
+ function test_wp_setup_nav_menu_item_for_post_type_archive () {
188
+
189
+ $ post_type_slug = rand_str ( 12 );
190
+ $ post_type_description = rand_str ();
191
+ register_post_type ( $ post_type_slug ,array (
192
+ 'public ' => true ,
193
+ 'has_archive ' => true ,
194
+ 'description ' => $ post_type_description ,
195
+ 'label ' => $ post_type_slug
196
+ ));
197
+
198
+ $ post_type_archive_item_id = wp_update_nav_menu_item ( $ this ->menu_id , 0 , array (
199
+ 'menu-item-type ' => 'post_type_archive ' ,
200
+ 'menu-item-object ' => $ post_type_slug ,
201
+ 'menu-item-description ' => $ post_type_description ,
202
+ 'menu-item-status ' => 'publish '
203
+ ) );
204
+ $ post_type_archive_item = wp_setup_nav_menu_item ( get_post ( $ post_type_archive_item_id ) );
205
+
206
+ $ this ->assertEquals ( $ post_type_slug , $ post_type_archive_item ->title );
207
+ $ this ->assertEquals ( $ post_type_description , $ post_type_archive_item ->description );
208
+ }
209
+
210
+ /**
211
+ * @ticket 35324
212
+ */
213
+ function test_wp_setup_nav_menu_item_for_post_type_archive_no_description () {
214
+
215
+ $ post_type_slug = rand_str ( 12 );
216
+ $ post_type_description = '' ;
217
+ register_post_type ( $ post_type_slug ,array (
218
+ 'public ' => true ,
219
+ 'has_archive ' => true ,
220
+ 'label ' => $ post_type_slug
221
+ ));
222
+
223
+ $ post_type_archive_item_id = wp_update_nav_menu_item ( $ this ->menu_id , 0 , array (
224
+ 'menu-item-type ' => 'post_type_archive ' ,
225
+ 'menu-item-object ' => $ post_type_slug ,
226
+ 'menu-item-status ' => 'publish '
227
+ ) );
228
+ $ post_type_archive_item = wp_setup_nav_menu_item ( get_post ( $ post_type_archive_item_id ) );
229
+
230
+ $ this ->assertEquals ( $ post_type_slug , $ post_type_archive_item ->title );
231
+ $ this ->assertEquals ( $ post_type_description , $ post_type_archive_item ->description ); //fail!!!
232
+ }
233
+
234
+ /**
235
+ * @ticket 35324
236
+ */
237
+ function test_wp_setup_nav_menu_item_for_post_type_archive_custom_description () {
238
+
239
+ $ post_type_slug = rand_str ( 12 );
240
+ $ post_type_description = rand_str ();
241
+ register_post_type ( $ post_type_slug ,array (
242
+ 'public ' => true ,
243
+ 'has_archive ' => true ,
244
+ 'description ' => $ post_type_description ,
245
+ 'label ' => $ post_type_slug
246
+ ));
247
+
248
+ $ menu_item_description = rand_str ();
249
+
250
+ $ post_type_archive_item_id = wp_update_nav_menu_item ( $ this ->menu_id , 0 , array (
251
+ 'menu-item-type ' => 'post_type_archive ' ,
252
+ 'menu-item-object ' => $ post_type_slug ,
253
+ 'menu-item-description ' => $ menu_item_description ,
254
+ 'menu-item-status ' => 'publish '
255
+ ) );
256
+ $ post_type_archive_item = wp_setup_nav_menu_item ( get_post ( $ post_type_archive_item_id ) );
257
+
258
+ $ this ->assertEquals ( $ post_type_slug , $ post_type_archive_item ->title );
259
+ $ this ->assertEquals ( $ menu_item_description , $ post_type_archive_item ->description );
260
+ }
183
261
}
0 commit comments