| | 278 | |
| | 279 | /** |
| | 280 | * Confirm Walker_Nav_Menu is passed a $args object. |
| | 281 | * |
| | 282 | * Walker_Nav_Menu is unique in that it uses an $args object rather than an array. |
| | 283 | * This has been the case for some time and should be maintained for reasons of |
| | 284 | * backward compatibility. |
| | 285 | * |
| | 286 | * @ticket 24587 |
| | 287 | */ |
| | 288 | function test_walker_nav_menu_is_passed_args_object() { |
| | 289 | $tag_id = self::factory()->tag->create(); |
| | 290 | |
| | 291 | $tag_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( |
| | 292 | 'menu-item-type' => 'taxonomy', |
| | 293 | 'menu-item-object' => 'post_tag', |
| | 294 | 'menu-item-object-id' => $tag_id, |
| | 295 | 'menu-item-status' => 'publish', |
| | 296 | ) ); |
| | 297 | |
| | 298 | /* |
| | 299 | * The tests take place in a filter to ensure the passed |
| | 300 | * arguments is an object. |
| | 301 | */ |
| | 302 | add_filter( 'nav_menu_item_args', array( $this, '_confirm_nav_menu_item_args_object' ) ); |
| | 303 | |
| | 304 | $actual = wp_nav_menu( array( |
| | 305 | 'echo' => false, |
| | 306 | 'menu' => $this->menu_id, |
| | 307 | ) ); |
| | 308 | |
| | 309 | wp_delete_term( $tag_id, 'post_tag' ); |
| | 310 | } |
| | 311 | |
| | 312 | /** |
| | 313 | * Run tests required to confrim Walker_Nav_Menu receives an $args object. |
| | 314 | */ |
| | 315 | function _confirm_nav_menu_item_args_object( $args ) { |
| | 316 | $this->assertTrue( is_object( $args ) ); |
| | 317 | return $args; |
| | 318 | } |