Changeset 42343 for trunk/tests/phpunit/tests/post/nav-menu.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/post/nav-menu.php (modified) (22 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/nav-menu.php
r41887 r42343 22 22 $tag_id = self::factory()->tag->create(); 23 23 24 wp_update_nav_menu_item( $this->menu_id, 0, array( 25 'menu-item-type' => 'taxonomy', 26 'menu-item-object' => 'post_tag', 27 'menu-item-object-id' => $tag_id, 28 'menu-item-status' => 'publish' 29 ) ); 30 31 $menu = wp_nav_menu( array( 32 'echo' => false, 33 'container' => '', 34 'menu' => $this->menu_id 35 ) ); 24 wp_update_nav_menu_item( 25 $this->menu_id, 0, array( 26 'menu-item-type' => 'taxonomy', 27 'menu-item-object' => 'post_tag', 28 'menu-item-object-id' => $tag_id, 29 'menu-item-status' => 'publish', 30 ) 31 ); 32 33 $menu = wp_nav_menu( 34 array( 35 'echo' => false, 36 'container' => '', 37 'menu' => $this->menu_id, 38 ) 39 ); 36 40 37 41 $this->assertEquals( 0, strpos( $menu, '<ul' ) ); … … 39 43 40 44 function test_wp_get_associated_nav_menu_items() { 41 $tag_id = self::factory()->tag->create();42 $cat_id = self::factory()->category->create();43 $post_id = self::factory()->post->create();45 $tag_id = self::factory()->tag->create(); 46 $cat_id = self::factory()->category->create(); 47 $post_id = self::factory()->post->create(); 44 48 $post_2_id = self::factory()->post->create(); 45 $page_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 46 47 $tag_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 48 'menu-item-type' => 'taxonomy', 49 'menu-item-object' => 'post_tag', 50 'menu-item-object-id' => $tag_id, 51 'menu-item-status' => 'publish' 52 ) ); 53 54 $cat_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 55 'menu-item-type' => 'taxonomy', 56 'menu-item-object' => 'category', 57 'menu-item-object-id' => $cat_id, 58 'menu-item-status' => 'publish' 59 ) ); 60 61 $post_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 62 'menu-item-type' => 'post_type', 63 'menu-item-object' => 'post', 64 'menu-item-object-id' => $post_id, 65 'menu-item-status' => 'publish' 66 ) ); 49 $page_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); 50 51 $tag_insert = wp_update_nav_menu_item( 52 $this->menu_id, 0, array( 53 'menu-item-type' => 'taxonomy', 54 'menu-item-object' => 'post_tag', 55 'menu-item-object-id' => $tag_id, 56 'menu-item-status' => 'publish', 57 ) 58 ); 59 60 $cat_insert = wp_update_nav_menu_item( 61 $this->menu_id, 0, array( 62 'menu-item-type' => 'taxonomy', 63 'menu-item-object' => 'category', 64 'menu-item-object-id' => $cat_id, 65 'menu-item-status' => 'publish', 66 ) 67 ); 68 69 $post_insert = wp_update_nav_menu_item( 70 $this->menu_id, 0, array( 71 'menu-item-type' => 'post_type', 72 'menu-item-object' => 'post', 73 'menu-item-object-id' => $post_id, 74 'menu-item-status' => 'publish', 75 ) 76 ); 67 77 68 78 // Item without menu-item-object arg 69 $post_2_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 70 'menu-item-type' => 'post_type', 71 'menu-item-object-id' => $post_2_id, 72 'menu-item-status' => 'publish' 73 ) ); 74 75 $page_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 76 'menu-item-type' => 'post_type', 77 'menu-item-object' => 'page', 78 'menu-item-object-id' => $page_id, 79 'menu-item-status' => 'publish' 80 ) ); 79 $post_2_insert = wp_update_nav_menu_item( 80 $this->menu_id, 0, array( 81 'menu-item-type' => 'post_type', 82 'menu-item-object-id' => $post_2_id, 83 'menu-item-status' => 'publish', 84 ) 85 ); 86 87 $page_insert = wp_update_nav_menu_item( 88 $this->menu_id, 0, array( 89 'menu-item-type' => 'post_type', 90 'menu-item-object' => 'page', 91 'menu-item-object-id' => $page_id, 92 'menu-item-status' => 'publish', 93 ) 94 ); 81 95 82 96 $tag_items = wp_get_associated_nav_menu_items( $tag_id, 'taxonomy', 'post_tag' ); … … 118 132 119 133 // Create an orphan nav menu item 120 $custom_item_id = wp_update_nav_menu_item( 0, 0, array( 121 'menu-item-type' => 'custom', 122 'menu-item-title' => 'Wordpress.org', 123 'menu-item-link' => 'http://wordpress.org', 124 'menu-item-status' => 'publish' 125 ) ); 134 $custom_item_id = wp_update_nav_menu_item( 135 0, 0, array( 136 'menu-item-type' => 'custom', 137 'menu-item-title' => 'Wordpress.org', 138 'menu-item-link' => 'http://wordpress.org', 139 'menu-item-status' => 'publish', 140 ) 141 ); 126 142 127 143 // Confirm it saved properly … … 130 146 131 147 // Update the orphan with an associated nav menu 132 wp_update_nav_menu_item( $this->menu_id, $custom_item_id, array( 133 'menu-item-title' => 'WordPress.org', 134 ) ); 135 $menu_items = wp_get_nav_menu_items( $this->menu_id ); 148 wp_update_nav_menu_item( 149 $this->menu_id, $custom_item_id, array( 150 'menu-item-title' => 'WordPress.org', 151 ) 152 ); 153 $menu_items = wp_get_nav_menu_items( $this->menu_id ); 136 154 $custom_item = wp_filter_object_list( $menu_items, array( 'db_id' => $custom_item_id ) ); 137 155 $custom_item = array_pop( $custom_item ); … … 142 160 public function test_wp_get_nav_menu_items_with_taxonomy_term() { 143 161 register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) ); 144 $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); 145 $child_terms = self::factory()->term->create_many( 2, array( 'taxonomy' => 'wptests_tax', 'parent' => $t ) ); 146 147 $term_menu_item = wp_update_nav_menu_item( $this->menu_id, 0, array( 148 'menu-item-type' => 'taxonomy', 149 'menu-item-object' => 'wptests_tax', 150 'menu-item-object-id' => $t, 151 'menu-item-status' => 'publish' 152 ) ); 162 $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); 163 $child_terms = self::factory()->term->create_many( 164 2, array( 165 'taxonomy' => 'wptests_tax', 166 'parent' => $t, 167 ) 168 ); 169 170 $term_menu_item = wp_update_nav_menu_item( 171 $this->menu_id, 0, array( 172 'menu-item-type' => 'taxonomy', 173 'menu-item-object' => 'wptests_tax', 174 'menu-item-object-id' => $t, 175 'menu-item-status' => 'publish', 176 ) 177 ); 153 178 154 179 $term = get_term( $t, 'wptests_tax' ); … … 170 195 171 196 // Assign the menu to the `primary` location. 172 $locations = get_nav_menu_locations();173 $menu_obj = wp_get_nav_menu_object( $menu );197 $locations = get_nav_menu_locations(); 198 $menu_obj = wp_get_nav_menu_object( $menu ); 174 199 $locations['primary'] = $menu_obj->term_id; 175 200 set_theme_mod( 'nav_menu_locations', $locations ); … … 191 216 // This is the expected array of menu names 192 217 $expected_nav_menus_names = wp_list_pluck( 193 get_terms( 'nav_menu', array( 'hide_empty' => false, 'orderby' => 'name' ) ), 218 get_terms( 219 'nav_menu', array( 220 'hide_empty' => false, 221 'orderby' => 'name', 222 ) 223 ), 194 224 'name' 195 225 ); … … 206 236 function test_wp_setup_nav_menu_item_for_post_type_archive() { 207 237 238 $post_type_slug = rand_str( 12 ); 239 $post_type_description = rand_str(); 240 register_post_type( 241 $post_type_slug, array( 242 'public' => true, 243 'has_archive' => true, 244 'description' => $post_type_description, 245 'label' => $post_type_slug, 246 ) 247 ); 248 249 $post_type_archive_item_id = wp_update_nav_menu_item( 250 $this->menu_id, 0, array( 251 'menu-item-type' => 'post_type_archive', 252 'menu-item-object' => $post_type_slug, 253 'menu-item-description' => $post_type_description, 254 'menu-item-status' => 'publish', 255 ) 256 ); 257 $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); 258 259 $this->assertEquals( $post_type_slug, $post_type_archive_item->title ); 260 $this->assertEquals( $post_type_description, $post_type_archive_item->description ); 261 } 262 263 /** 264 * @ticket 35324 265 */ 266 function test_wp_setup_nav_menu_item_for_post_type_archive_no_description() { 267 268 $post_type_slug = rand_str( 12 ); 269 $post_type_description = ''; 270 register_post_type( 271 $post_type_slug, array( 272 'public' => true, 273 'has_archive' => true, 274 'label' => $post_type_slug, 275 ) 276 ); 277 278 $post_type_archive_item_id = wp_update_nav_menu_item( 279 $this->menu_id, 0, array( 280 'menu-item-type' => 'post_type_archive', 281 'menu-item-object' => $post_type_slug, 282 'menu-item-status' => 'publish', 283 ) 284 ); 285 $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); 286 287 $this->assertEquals( $post_type_slug, $post_type_archive_item->title ); 288 $this->assertEquals( $post_type_description, $post_type_archive_item->description ); //fail!!! 289 } 290 291 /** 292 * @ticket 35324 293 */ 294 function test_wp_setup_nav_menu_item_for_post_type_archive_custom_description() { 295 296 $post_type_slug = rand_str( 12 ); 297 $post_type_description = rand_str(); 298 register_post_type( 299 $post_type_slug, array( 300 'public' => true, 301 'has_archive' => true, 302 'description' => $post_type_description, 303 'label' => $post_type_slug, 304 ) 305 ); 306 307 $menu_item_description = rand_str(); 308 309 $post_type_archive_item_id = wp_update_nav_menu_item( 310 $this->menu_id, 0, array( 311 'menu-item-type' => 'post_type_archive', 312 'menu-item-object' => $post_type_slug, 313 'menu-item-description' => $menu_item_description, 314 'menu-item-status' => 'publish', 315 ) 316 ); 317 $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); 318 319 $this->assertEquals( $post_type_slug, $post_type_archive_item->title ); 320 $this->assertEquals( $menu_item_description, $post_type_archive_item->description ); 321 } 322 323 /** 324 * @ticket 35324 325 */ 326 function test_wp_setup_nav_menu_item_for_unknown_post_type_archive_no_description() { 327 208 328 $post_type_slug = rand_str( 12 ); 209 $post_type_description = rand_str(); 210 register_post_type( $post_type_slug ,array( 211 'public' => true, 212 'has_archive' => true, 213 'description' => $post_type_description, 214 'label' => $post_type_slug 215 )); 216 217 $post_type_archive_item_id = wp_update_nav_menu_item( $this->menu_id, 0, array( 218 'menu-item-type' => 'post_type_archive', 219 'menu-item-object' => $post_type_slug, 220 'menu-item-description' => $post_type_description, 221 'menu-item-status' => 'publish' 222 ) ); 223 $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); 224 225 $this->assertEquals( $post_type_slug , $post_type_archive_item->title ); 226 $this->assertEquals( $post_type_description , $post_type_archive_item->description ); 227 } 228 229 /** 230 * @ticket 35324 231 */ 232 function test_wp_setup_nav_menu_item_for_post_type_archive_no_description() { 233 234 $post_type_slug = rand_str( 12 ); 235 $post_type_description = ''; 236 register_post_type( $post_type_slug ,array( 237 'public' => true, 238 'has_archive' => true, 239 'label' => $post_type_slug 240 )); 241 242 $post_type_archive_item_id = wp_update_nav_menu_item( $this->menu_id, 0, array( 243 'menu-item-type' => 'post_type_archive', 244 'menu-item-object' => $post_type_slug, 245 'menu-item-status' => 'publish' 246 ) ); 247 $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); 248 249 $this->assertEquals( $post_type_slug , $post_type_archive_item->title ); 250 $this->assertEquals( $post_type_description , $post_type_archive_item->description ); //fail!!! 251 } 252 253 /** 254 * @ticket 35324 255 */ 256 function test_wp_setup_nav_menu_item_for_post_type_archive_custom_description() { 257 258 $post_type_slug = rand_str( 12 ); 259 $post_type_description = rand_str(); 260 register_post_type( $post_type_slug ,array( 261 'public' => true, 262 'has_archive' => true, 263 'description' => $post_type_description, 264 'label' => $post_type_slug 265 )); 266 267 $menu_item_description = rand_str(); 268 269 $post_type_archive_item_id = wp_update_nav_menu_item( $this->menu_id, 0, array( 270 'menu-item-type' => 'post_type_archive', 271 'menu-item-object' => $post_type_slug, 272 'menu-item-description' => $menu_item_description, 273 'menu-item-status' => 'publish' 274 ) ); 275 $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); 276 277 $this->assertEquals( $post_type_slug , $post_type_archive_item->title ); 278 $this->assertEquals( $menu_item_description , $post_type_archive_item->description ); 279 } 280 281 /** 282 * @ticket 35324 283 */ 284 function test_wp_setup_nav_menu_item_for_unknown_post_type_archive_no_description() { 285 286 $post_type_slug = rand_str( 12 ); 287 288 $post_type_archive_item_id = wp_update_nav_menu_item( $this->menu_id, 0, array( 289 'menu-item-type' => 'post_type_archive', 290 'menu-item-object' => $post_type_slug, 291 'menu-item-status' => 'publish' 292 ) ); 293 $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); 329 330 $post_type_archive_item_id = wp_update_nav_menu_item( 331 $this->menu_id, 0, array( 332 'menu-item-type' => 'post_type_archive', 333 'menu-item-object' => $post_type_slug, 334 'menu-item-status' => 'publish', 335 ) 336 ); 337 $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); 294 338 295 339 $this->assertEmpty( $post_type_archive_item->description ); … … 300 344 */ 301 345 function test_wp_setup_nav_menu_item_for_trashed_post() { 302 $post_id = self::factory()->post->create( array( 303 'post_status' => 'trash', 304 ) ); 305 306 $menu_item_id = wp_update_nav_menu_item( $this->menu_id, 0, array( 307 'menu-item-type' => 'post_type', 308 'menu-item-object' => 'post', 309 'menu-item-object-id' => $post_id, 310 'menu-item-status' => 'publish', 311 ) ); 346 $post_id = self::factory()->post->create( 347 array( 348 'post_status' => 'trash', 349 ) 350 ); 351 352 $menu_item_id = wp_update_nav_menu_item( 353 $this->menu_id, 0, array( 354 'menu-item-type' => 'post_type', 355 'menu-item-object' => 'post', 356 'menu-item-object-id' => $post_id, 357 'menu-item-status' => 'publish', 358 ) 359 ); 312 360 313 361 $menu_item = wp_setup_nav_menu_item( get_post( $menu_item_id ) ); … … 325 373 $post_id4 = self::factory()->post->create(); 326 374 327 $post_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 328 'menu-item-type' => 'post_type', 329 'menu-item-object' => 'post', 330 'menu-item-object-id' => $post_id1, 331 'menu-item-status' => 'publish' 332 ) ); 333 334 $post_inser2 = wp_update_nav_menu_item( $this->menu_id, 0, array( 335 'menu-item-type' => 'post_type', 336 'menu-item-object' => 'post', 337 'menu-item-object-id' => $post_id2, 338 'menu-item-status' => 'publish' 339 ) ); 340 341 $post_insert3 = wp_update_nav_menu_item( $this->menu_id, 0, array( 342 'menu-item-type' => 'post_type', 343 'menu-item-object' => 'post', 344 'menu-item-parent-id' => $post_insert, 345 'menu-item-object-id' => $post_id3, 346 'menu-item-status' => 'publish' 347 ) ); 348 349 $post_insert4 = wp_update_nav_menu_item( $this->menu_id, 0, array( 350 'menu-item-type' => 'post_type', 351 'menu-item-object' => 'post', 352 'menu-item-parent-id' => $post_insert, 353 'menu-item-object-id' => $post_id4, 354 'menu-item-status' => 'publish' 355 ) ); 375 $post_insert = wp_update_nav_menu_item( 376 $this->menu_id, 0, array( 377 'menu-item-type' => 'post_type', 378 'menu-item-object' => 'post', 379 'menu-item-object-id' => $post_id1, 380 'menu-item-status' => 'publish', 381 ) 382 ); 383 384 $post_inser2 = wp_update_nav_menu_item( 385 $this->menu_id, 0, array( 386 'menu-item-type' => 'post_type', 387 'menu-item-object' => 'post', 388 'menu-item-object-id' => $post_id2, 389 'menu-item-status' => 'publish', 390 ) 391 ); 392 393 $post_insert3 = wp_update_nav_menu_item( 394 $this->menu_id, 0, array( 395 'menu-item-type' => 'post_type', 396 'menu-item-object' => 'post', 397 'menu-item-parent-id' => $post_insert, 398 'menu-item-object-id' => $post_id3, 399 'menu-item-status' => 'publish', 400 ) 401 ); 402 403 $post_insert4 = wp_update_nav_menu_item( 404 $this->menu_id, 0, array( 405 'menu-item-type' => 'post_type', 406 'menu-item-object' => 'post', 407 'menu-item-parent-id' => $post_insert, 408 'menu-item-object-id' => $post_id4, 409 'menu-item-status' => 'publish', 410 ) 411 ); 356 412 357 413 // No whitespace suppression. 358 $menu = wp_nav_menu( array( 359 'echo' => false, 360 'menu' => $this->menu_id, 361 ) ); 414 $menu = wp_nav_menu( 415 array( 416 'echo' => false, 417 'menu' => $this->menu_id, 418 ) 419 ); 362 420 363 421 // The markup should include whitespace between <li>s … … 365 423 $this->assertNotRegExp( '/<\/li><li.*>/U', $menu ); 366 424 367 368 425 // Whitepsace suppressed. 369 $menu = wp_nav_menu( array( 370 'echo' => false, 371 'item_spacing' => 'discard', 372 'menu' => $this->menu_id, 373 ) ); 426 $menu = wp_nav_menu( 427 array( 428 'echo' => false, 429 'item_spacing' => 'discard', 430 'menu' => $this->menu_id, 431 ) 432 ); 374 433 375 434 // The markup should not include whitespace around <li>s … … 390 449 $tag_id = self::factory()->tag->create(); 391 450 392 $tag_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 393 'menu-item-type' => 'taxonomy', 394 'menu-item-object' => 'post_tag', 395 'menu-item-object-id' => $tag_id, 396 'menu-item-status' => 'publish', 397 ) ); 451 $tag_insert = wp_update_nav_menu_item( 452 $this->menu_id, 0, array( 453 'menu-item-type' => 'taxonomy', 454 'menu-item-object' => 'post_tag', 455 'menu-item-object-id' => $tag_id, 456 'menu-item-status' => 'publish', 457 ) 458 ); 398 459 399 460 /* … … 402 463 */ 403 464 // In function. 404 add_filter( 'pre_wp_nav_menu', array( $this, '_confirm_second_param_args_object' ), 10, 2 );405 add_filter( 'wp_nav_menu_objects', array( $this, '_confirm_second_param_args_object' ), 10, 2 );406 add_filter( 'wp_nav_menu_items', array( $this, '_confirm_second_param_args_object' ), 10, 2 );465 add_filter( 'pre_wp_nav_menu', array( $this, '_confirm_second_param_args_object' ), 10, 2 ); 466 add_filter( 'wp_nav_menu_objects', array( $this, '_confirm_second_param_args_object' ), 10, 2 ); 467 add_filter( 'wp_nav_menu_items', array( $this, '_confirm_second_param_args_object' ), 10, 2 ); 407 468 408 469 // In walker. 409 add_filter( 'nav_menu_item_args', array( $this, '_confirm_nav_menu_item_args_object' ) );410 411 add_filter( 'nav_menu_css_class', array( $this, '_confirm_third_param_args_object' ), 10, 3 );412 add_filter( 'nav_menu_item_id', array( $this, '_confirm_third_param_args_object' ), 10, 3 );470 add_filter( 'nav_menu_item_args', array( $this, '_confirm_nav_menu_item_args_object' ) ); 471 472 add_filter( 'nav_menu_css_class', array( $this, '_confirm_third_param_args_object' ), 10, 3 ); 473 add_filter( 'nav_menu_item_id', array( $this, '_confirm_third_param_args_object' ), 10, 3 ); 413 474 add_filter( 'nav_menu_link_attributes', array( $this, '_confirm_third_param_args_object' ), 10, 3 ); 414 add_filter( 'nav_menu_item_title', array( $this, '_confirm_third_param_args_object' ), 10, 3 );475 add_filter( 'nav_menu_item_title', array( $this, '_confirm_third_param_args_object' ), 10, 3 ); 415 476 416 477 add_filter( 'walker_nav_menu_start_el', array( $this, '_confirm_forth_param_args_object' ), 10, 4 ); 417 478 418 wp_nav_menu( array( 419 'echo' => false, 420 'menu' => $this->menu_id, 421 ) ); 479 wp_nav_menu( 480 array( 481 'echo' => false, 482 'menu' => $this->menu_id, 483 ) 484 ); 422 485 wp_delete_term( $tag_id, 'post_tag' ); 423 486 … … 426 489 */ 427 490 // In function. 428 remove_filter( 'pre_wp_nav_menu', array( $this, '_confirm_second_param_args_object' ), 10, 2 );429 remove_filter( 'wp_nav_menu_objects', array( $this, '_confirm_second_param_args_object' ), 10, 2 );430 remove_filter( 'wp_nav_menu_items', array( $this, '_confirm_second_param_args_object' ), 10, 2 );491 remove_filter( 'pre_wp_nav_menu', array( $this, '_confirm_second_param_args_object' ), 10, 2 ); 492 remove_filter( 'wp_nav_menu_objects', array( $this, '_confirm_second_param_args_object' ), 10, 2 ); 493 remove_filter( 'wp_nav_menu_items', array( $this, '_confirm_second_param_args_object' ), 10, 2 ); 431 494 432 495 // In walker. 433 remove_filter( 'nav_menu_item_args', array( $this, '_confirm_nav_menu_item_args_object' ) );434 435 remove_filter( 'nav_menu_css_class', array( $this, '_confirm_third_param_args_object' ), 10, 3 );436 remove_filter( 'nav_menu_item_id', array( $this, '_confirm_third_param_args_object' ), 10, 3 );496 remove_filter( 'nav_menu_item_args', array( $this, '_confirm_nav_menu_item_args_object' ) ); 497 498 remove_filter( 'nav_menu_css_class', array( $this, '_confirm_third_param_args_object' ), 10, 3 ); 499 remove_filter( 'nav_menu_item_id', array( $this, '_confirm_third_param_args_object' ), 10, 3 ); 437 500 remove_filter( 'nav_menu_link_attributes', array( $this, '_confirm_third_param_args_object' ), 10, 3 ); 438 remove_filter( 'nav_menu_item_title', array( $this, '_confirm_third_param_args_object' ), 10, 3 );501 remove_filter( 'nav_menu_item_title', array( $this, '_confirm_third_param_args_object' ), 10, 3 ); 439 502 440 503 remove_filter( 'walker_nav_menu_start_el', array( $this, '_confirm_forth_param_args_object' ), 10, 4 ); … … 470 533 */ 471 534 function test_no_front_page_class_applied() { 472 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Home Page' ) ); 473 474 wp_update_nav_menu_item( $this->menu_id, 0, array( 475 'menu-item-type' => 'post_type', 476 'menu-item-object' => 'page', 477 'menu-item-object-id' => $page_id, 478 'menu-item-status' => 'publish', 479 )); 535 $page_id = self::factory()->post->create( 536 array( 537 'post_type' => 'page', 538 'post_title' => 'Home Page', 539 ) 540 ); 541 542 wp_update_nav_menu_item( 543 $this->menu_id, 0, array( 544 'menu-item-type' => 'post_type', 545 'menu-item-object' => 'page', 546 'menu-item-object-id' => $page_id, 547 'menu-item-status' => 'publish', 548 ) 549 ); 480 550 481 551 $menu_items = wp_get_nav_menu_items( $this->menu_id ); … … 492 562 */ 493 563 function test_class_applied_to_front_page_item() { 494 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Home Page' ) ); 564 $page_id = self::factory()->post->create( 565 array( 566 'post_type' => 'page', 567 'post_title' => 'Home Page', 568 ) 569 ); 495 570 update_option( 'page_on_front', $page_id ); 496 571 497 wp_update_nav_menu_item( $this->menu_id, 0, array( 498 'menu-item-type' => 'post_type', 499 'menu-item-object' => 'page', 500 'menu-item-object-id' => $page_id, 501 'menu-item-status' => 'publish', 502 )); 572 wp_update_nav_menu_item( 573 $this->menu_id, 0, array( 574 'menu-item-type' => 'post_type', 575 'menu-item-object' => 'page', 576 'menu-item-object-id' => $page_id, 577 'menu-item-status' => 'publish', 578 ) 579 ); 503 580 504 581 $menu_items = wp_get_nav_menu_items( $this->menu_id ); … … 520 597 $new_id = 35272; 521 598 522 $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Home Page' ) ); 523 $tag_id = self::factory()->tag->create(); 599 $page_id = self::factory()->post->create( 600 array( 601 'post_type' => 'page', 602 'post_title' => 'Home Page', 603 ) 604 ); 605 $tag_id = self::factory()->tag->create(); 524 606 525 607 $wpdb->query( "UPDATE $wpdb->posts SET ID=$new_id WHERE ID=$page_id" ); … … 529 611 update_option( 'page_on_front', $new_id ); 530 612 531 wp_update_nav_menu_item( $this->menu_id, 0, array( 532 'menu-item-type' => 'taxonomy', 533 'menu-item-object' => 'post_tag', 534 'menu-item-object-id' => $new_id, 535 'menu-item-status' => 'publish', 536 ) ); 613 wp_update_nav_menu_item( 614 $this->menu_id, 0, array( 615 'menu-item-type' => 'taxonomy', 616 'menu-item-object' => 'post_tag', 617 'menu-item-object-id' => $new_id, 618 'menu-item-status' => 'publish', 619 ) 620 ); 537 621 538 622 $menu_items = wp_get_nav_menu_items( $this->menu_id ); … … 550 634 */ 551 635 function test_wp_delete_customize_changeset_dependent_auto_drafts() { 552 $auto_draft_post_id = $this->factory()->post->create( array( 553 'post_status' => 'auto-draft', 554 ) ); 555 $draft_post_id = $this->factory()->post->create( array( 556 'post_status' => 'draft', 557 ) ); 558 $private_post_id = $this->factory()->post->create( array( 559 'post_status' => 'private', 560 ) ); 636 $auto_draft_post_id = $this->factory()->post->create( 637 array( 638 'post_status' => 'auto-draft', 639 ) 640 ); 641 $draft_post_id = $this->factory()->post->create( 642 array( 643 'post_status' => 'draft', 644 ) 645 ); 646 $private_post_id = $this->factory()->post->create( 647 array( 648 'post_status' => 'private', 649 ) 650 ); 561 651 562 652 $nav_created_post_ids = array( … … 565 655 $private_post_id, 566 656 ); 567 $data = array(657 $data = array( 568 658 'nav_menus_created_posts' => array( 569 659 'value' => $nav_created_post_ids, 570 660 ), 571 661 ); 572 wp_set_current_user( self::factory()->user->create( array( 573 'role' => 'administrator', 574 ) ) ); 662 wp_set_current_user( 663 self::factory()->user->create( 664 array( 665 'role' => 'administrator', 666 ) 667 ) 668 ); 575 669 require_once ABSPATH . WPINC . '/class-wp-customize-manager.php'; 576 670 $wp_customize = new WP_Customize_Manager(); 577 671 do_action( 'customize_register', $wp_customize ); 578 $wp_customize->save_changeset_post( array( 579 'data' => $data, 580 ) ); 672 $wp_customize->save_changeset_post( 673 array( 674 'data' => $data, 675 ) 676 ); 581 677 $this->assertEquals( 'auto-draft', get_post_status( $auto_draft_post_id ) ); 582 678 $this->assertEquals( 'draft', get_post_status( $draft_post_id ) ); … … 593 689 function test_parent_ancestor_for_post_archive() { 594 690 595 register_post_type( 'books', array( 'label' => 'Books', 'public' => true, 'has_archive' => true ) ); 596 597 $first_page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Top Level Page' ) ); 598 $second_page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_title' => 'Second Level Page' ) ); 599 600 601 $first_menu_id = wp_update_nav_menu_item( $this->menu_id, 0, array( 602 'menu-item-type' => 'post_type', 603 'menu-item-object' => 'page', 604 'menu-item-object-id' => $first_page_id, 605 'menu-item-status' => 'publish', 606 )); 607 608 $second_menu_id = wp_update_nav_menu_item( $this->menu_id, 0, array( 609 'menu-item-type' => 'post_type', 610 'menu-item-object' => 'page', 611 'menu-item-object-id' => $second_page_id, 612 'menu-item-status' => 'publish', 613 'menu-item-parent-id' => $first_menu_id 614 )); 615 616 wp_update_nav_menu_item( $this->menu_id, 0, array( 617 'menu-item-type' => 'post_type_archive', 618 'menu-item-object' => 'books', 619 'menu-item-status' => 'publish', 620 'menu-item-parent-id' => $second_menu_id 621 )); 691 register_post_type( 692 'books', array( 693 'label' => 'Books', 694 'public' => true, 695 'has_archive' => true, 696 ) 697 ); 698 699 $first_page_id = self::factory()->post->create( 700 array( 701 'post_type' => 'page', 702 'post_title' => 'Top Level Page', 703 ) 704 ); 705 $second_page_id = self::factory()->post->create( 706 array( 707 'post_type' => 'page', 708 'post_title' => 'Second Level Page', 709 ) 710 ); 711 712 $first_menu_id = wp_update_nav_menu_item( 713 $this->menu_id, 0, array( 714 'menu-item-type' => 'post_type', 715 'menu-item-object' => 'page', 716 'menu-item-object-id' => $first_page_id, 717 'menu-item-status' => 'publish', 718 ) 719 ); 720 721 $second_menu_id = wp_update_nav_menu_item( 722 $this->menu_id, 0, array( 723 'menu-item-type' => 'post_type', 724 'menu-item-object' => 'page', 725 'menu-item-object-id' => $second_page_id, 726 'menu-item-status' => 'publish', 727 'menu-item-parent-id' => $first_menu_id, 728 ) 729 ); 730 731 wp_update_nav_menu_item( 732 $this->menu_id, 0, array( 733 'menu-item-type' => 'post_type_archive', 734 'menu-item-object' => 'books', 735 'menu-item-status' => 'publish', 736 'menu-item-parent-id' => $second_menu_id, 737 ) 738 ); 622 739 623 740 $this->go_to( get_post_type_archive_link( 'books' ) ); … … 635 752 636 753 $this->assertTrue( $secondary_page_menu_item->current_item_parent ); 637 $this->assertTrue( $secondary_page_menu_item->current_item_ancestor );754 $this->assertTrue( $secondary_page_menu_item->current_item_ancestor ); 638 755 $this->assertContains( 'current-menu-parent', $secondary_page_menu_item->classes ); 639 756 $this->assertContains( 'current-menu-ancestor', $secondary_page_menu_item->classes ); 640 757 641 758 $this->assertFalse( $post_archive_menu_item->current_item_parent ); 642 $this->assertFalse( $post_archive_menu_item->current_item_ancestor );759 $this->assertFalse( $post_archive_menu_item->current_item_ancestor ); 643 760 644 761 $this->assertNotContains( 'current-menu-parent', $post_archive_menu_item->classes );
Note: See TracChangeset
for help on using the changeset viewer.