- Timestamp:
- 11/27/2016 03:04:35 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/nav-menu-item-setting.php
r38858 r39365 835 835 836 836 /** 837 * Test WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item() to set url for posts, terms, and post type archives. 838 * 839 * @ticket 38945 840 * @covers WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item() 841 */ 842 function test_value_as_wp_post_nav_menu_item_term_urls() { 843 $term_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) ); 844 register_post_type( 'press_release', array( 845 'has_archive' => true, 846 ) ); 847 $post_id = self::factory()->post->create( array( 'post_type' => 'press_release' ) ); 848 849 // Term. 850 $setting = new WP_Customize_Nav_Menu_Item_Setting( 851 $this->wp_customize, 852 'nav_menu_item[-1]' 853 ); 854 $this->wp_customize->set_post_value( $setting->id, array( 855 'type' => 'taxonomy', 856 'object' => 'category', 857 'object_id' => $term_id, 858 'title' => 'Category', 859 'url' => '', 860 ) ); 861 $setting->preview(); 862 $nav_menu_item = $setting->value_as_wp_post_nav_menu_item(); 863 $this->assertEquals( get_term_link( $term_id ), $nav_menu_item->url ); 864 865 // Post. 866 $setting = new WP_Customize_Nav_Menu_Item_Setting( 867 $this->wp_customize, 868 'nav_menu_item[-2]' 869 ); 870 $this->wp_customize->set_post_value( $setting->id, array( 871 'type' => 'post_type', 872 'object' => 'press_release', 873 'object_id' => $post_id, 874 'title' => 'PR', 875 'url' => '', 876 ) ); 877 $setting->preview(); 878 $nav_menu_item = $setting->value_as_wp_post_nav_menu_item(); 879 $this->assertEquals( get_permalink( $post_id ), $nav_menu_item->url ); 880 881 // Post type archive. 882 $setting = new WP_Customize_Nav_Menu_Item_Setting( 883 $this->wp_customize, 884 'nav_menu_item[-3]' 885 ); 886 $this->wp_customize->set_post_value( $setting->id, array( 887 'type' => 'post_type_archive', 888 'object' => 'press_release', 889 'title' => 'PR', 890 'url' => '', 891 ) ); 892 $setting->preview(); 893 $nav_menu_item = $setting->value_as_wp_post_nav_menu_item(); 894 $this->assertEquals( get_post_type_archive_link( 'press_release' ), $nav_menu_item->url ); 895 } 896 897 /** 837 898 * Test WP_Customize_Nav_Menu_Item_Setting::value_as_wp_post_nav_menu_item() where title is empty. 838 899 *
Note: See TracChangeset
for help on using the changeset viewer.