- Timestamp:
- 07/22/2015 08:28:03 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/nav-menu-item-setting.php
r32806 r33366 36 36 $wp_customize = null; 37 37 parent::clean_up_global_scope(); 38 } 39 40 /** 41 * Filter to add a custom menu item type label. 42 * 43 * @param object $menu_item Menu item. 44 * @return object 45 */ 46 function filter_type_label( $menu_item ) { 47 if ( 'custom_type' === $menu_item->type ) { 48 $menu_item->type_label = 'Custom Label'; 49 } 50 51 return $menu_item; 38 52 } 39 53 … … 207 221 208 222 /** 223 * Test value method with a custom object. 224 * 225 * @see WP_Customize_Nav_Menu_Item_Setting::value() 226 */ 227 function test_custom_type_label() { 228 do_action( 'customize_register', $this->wp_customize ); 229 add_filter( 'wp_setup_nav_menu_item', array( $this, 'filter_type_label' ) ); 230 231 $menu_id = wp_create_nav_menu( 'Menu' ); 232 $item_id = wp_update_nav_menu_item( $menu_id, 0, array( 233 'menu-item-type' => 'custom_type', 234 'menu-item-object' => 'custom_object', 235 'menu-item-title' => 'Cool beans', 236 'menu-item-status' => 'publish', 237 ) ); 238 239 $post = get_post( $item_id ); 240 $menu_item = wp_setup_nav_menu_item( $post ); 241 242 $setting_id = "nav_menu_item[$item_id]"; 243 $setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id ); 244 245 $value = $setting->value(); 246 $this->assertEquals( $menu_item->type_label, 'Custom Label' ); 247 $this->assertEquals( $menu_item->type_label, $value['type_label'] ); 248 } 249 250 /** 209 251 * Test value method returns zero for nav_menu_term_id when previewing a new menu. 210 252 *
Note: See TracChangeset
for help on using the changeset viewer.