- Timestamp:
- 11/09/2016 08:42:22 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/custom-css-setting.php
r39175 r39185 46 46 47 47 do_action( 'customize_register', $this->wp_customize ); 48 $this->setting = new WP_Customize_Custom_CSS_Setting( $this->wp_customize, 'custom_css[ twentysixteen]' );48 $this->setting = new WP_Customize_Custom_CSS_Setting( $this->wp_customize, 'custom_css[' . get_stylesheet() . ']' ); 49 49 $this->wp_customize->add_setting( $this->setting ); 50 50 } … … 79 79 $this->assertTrue( post_type_exists( 'custom_css' ) ); 80 80 $this->assertEquals( 'custom_css', $this->setting->type ); 81 $this->assertEquals( 'twentysixteen', $this->setting->stylesheet );81 $this->assertEquals( get_stylesheet(), $this->setting->stylesheet ); 82 82 $this->assertEquals( 'edit_css', $this->setting->capability ); 83 83 … … 114 114 $this->assertEquals( $this->setting->default, $this->setting->value() ); 115 115 116 $this->assertNull( wp_get_custom_css_post() ); 117 $this->assertNull( wp_get_custom_css_post( $this->setting->stylesheet ) ); 118 $this->assertNull( wp_get_custom_css_post( 'twentyten' ) ); 119 116 120 $original_css = 'body { color: black; }'; 117 $ this->factory()->post->create( array(121 $post_id = $this->factory()->post->create( array( 118 122 'post_title' => $this->setting->stylesheet, 119 123 'post_name' => $this->setting->stylesheet, 120 'post_content' => 'body { color: black; }',124 'post_content' => $original_css, 121 125 'post_status' => 'publish', 122 126 'post_type' => 'custom_css', 123 127 ) ); 128 $twentyten_css = 'body { color: red; }'; 129 $twentyten_post_id = $this->factory()->post->create( array( 130 'post_title' => 'twentyten', 131 'post_name' => 'twentyten', 132 'post_content' => $twentyten_css, 133 'post_status' => 'publish', 134 'post_type' => 'custom_css', 135 ) ); 136 $twentyten_setting = new WP_Customize_Custom_CSS_Setting( $this->wp_customize, 'custom_css[twentyten]' ); 137 138 $this->assertEquals( $post_id, wp_get_custom_css_post()->ID ); 139 $this->assertEquals( $post_id, wp_get_custom_css_post( $this->setting->stylesheet )->ID ); 140 $this->assertEquals( $twentyten_post_id, wp_get_custom_css_post( 'twentyten' )->ID ); 124 141 125 142 $this->assertEquals( $original_css, wp_get_custom_css( $this->setting->stylesheet ) ); 126 143 $this->assertEquals( $original_css, $this->setting->value() ); 144 $this->assertEquals( $twentyten_css, wp_get_custom_css( 'twentyten' ) ); 145 $this->assertEquals( $twentyten_css, $twentyten_setting->value() ); 127 146 128 147 $updated_css = 'body { color: blue; }'; … … 139 158 $this->assertEquals( $previewed_css, $this->setting->value() ); 140 159 $this->assertEquals( $previewed_css, wp_get_custom_css( $this->setting->stylesheet ) ); 160 161 wp_delete_post( $post_id ); 162 $this->assertNull( wp_get_custom_css_post() ); 163 $this->assertNull( wp_get_custom_css_post( get_stylesheet() ) ); 164 $this->assertEquals( $previewed_css, wp_get_custom_css( get_stylesheet() ), 'Previewed value remains in spite of deleted post.' ); 165 wp_delete_post( $twentyten_post_id ); 166 $this->assertNull( wp_get_custom_css_post( 'twentyten' ) ); 167 $this->assertEquals( '', wp_get_custom_css( 'twentyten' ) ); 141 168 } 142 169
Note: See TracChangeset
for help on using the changeset viewer.