Changeset 38906 for trunk/tests/phpunit/tests/customize/control.php
- Timestamp:
- 10/25/2016 06:30:27 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/customize/control.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/control.php
r38858 r38906 27 27 function setUp() { 28 28 parent::setUp(); 29 wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) ); 29 30 require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' ); 30 31 // @codingStandardsIgnoreStart … … 40 41 */ 41 42 function test_check_capabilities() { 42 wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );43 43 do_action( 'customize_register', $this->wp_customize ); 44 44 $control = new WP_Customize_Control( $this->wp_customize, 'blogname', array( … … 79 79 80 80 /** 81 * @ticket 38164 82 */ 83 function test_dropdown_pages() { 84 do_action( 'customize_register', $this->wp_customize ); 85 86 $this->assertInstanceOf( 'WP_Customize_Nav_Menus', $this->wp_customize->nav_menus ); 87 $nav_menus_created_posts_setting = $this->wp_customize->get_setting( 'nav_menus_created_posts' ); 88 $this->assertInstanceOf( 'WP_Customize_Filter_Setting', $nav_menus_created_posts_setting ); 89 $page_on_front_control = $this->wp_customize->get_control( 'page_on_front' ); 90 91 // Ensure the add-new-toggle is absent if allow_addition param is not set. 92 $page_on_front_control->allow_addition = false; 93 ob_start(); 94 $page_on_front_control->maybe_render(); 95 $content = ob_get_clean(); 96 $this->assertNotContains( 'add-new-toggle', $content ); 97 98 // Ensure the add-new-toggle is absent if allow_addition param is set. 99 $page_on_front_control->allow_addition = true; 100 ob_start(); 101 $page_on_front_control->maybe_render(); 102 $content = ob_get_clean(); 103 $this->assertContains( 'add-new-toggle', $content ); 104 105 // Ensure that dropdown-pages delect is rendered even if there are no pages published (yet). 106 foreach ( get_pages() as $page ) { 107 wp_delete_post( $page->ID ); 108 } 109 $page_on_front_control->allow_addition = true; 110 ob_start(); 111 $page_on_front_control->maybe_render(); 112 $content = ob_get_clean(); 113 $this->assertContains( '<option value="0">', $content, 'Dropdown-pages renders select even without any pages published.' ); 114 115 // Ensure that auto-draft pages are included if they are among the nav_menus_created_posts. 116 $auto_draft_page_id = $this->factory()->post->create( array( 117 'post_type' => 'page', 118 'post_status' => 'auto-draft', 119 'post_title' => 'Auto Draft Page', 120 ) ); 121 $this->factory()->post->create( array( 122 'post_type' => 'page', 123 'post_status' => 'auto-draft', 124 'post_title' => 'Orphan Auto Draft Page', 125 ) ); 126 $auto_draft_post_id = $this->factory()->post->create( array( 127 'post_type' => 'post', 128 'post_status' => 'auto-draft', 129 'post_title' => 'Auto Draft Post', 130 ) ); 131 $this->wp_customize->set_post_value( $nav_menus_created_posts_setting->id, array( $auto_draft_page_id, $auto_draft_post_id ) ); 132 $nav_menus_created_posts_setting->preview(); 133 ob_start(); 134 $page_on_front_control->maybe_render(); 135 $content = ob_get_clean(); 136 $this->assertContains( sprintf( '<option value="%d">Auto Draft Page</option>', $auto_draft_page_id ), $content ); 137 $this->assertNotContains( 'Auto Draft Post', $content ); 138 $this->assertNotContains( 'Orphan Auto Draft Page', $content ); 139 } 140 141 /** 81 142 * Tear down. 82 143 */
Note: See TracChangeset
for help on using the changeset viewer.