- Timestamp:
- 11/23/2016 05:33:21 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/custom-css-setting.php
r39209 r39350 152 152 $this->assertEquals( $updated_css, $this->setting->value() ); 153 153 $this->assertEquals( $updated_css, wp_get_custom_css( $this->setting->stylesheet ) ); 154 $this->assertEquals( $updated_css, get_post( $post_id )->post_content ); 154 155 155 156 $previewed_css = 'body { color: red; }'; … … 159 160 $this->assertEquals( $previewed_css, wp_get_custom_css( $this->setting->stylesheet ) ); 160 161 162 // Make sure that wp_update_custom_css_post() works as expected for updates. 163 $r = wp_update_custom_css_post( 'body { color:red; }', array( 164 'stylesheet' => $this->setting->stylesheet, 165 'preprocessed' => "body\n\tcolor:red;", 166 ) ); 167 $this->assertInstanceOf( 'WP_Post', $r ); 168 $this->assertEquals( $post_id, $r->ID ); 169 $this->assertEquals( 'body { color:red; }', get_post( $r )->post_content ); 170 $this->assertEquals( "body\n\tcolor:red;", get_post( $r )->post_content_filtered ); 171 $r = wp_update_custom_css_post( 'body { content: "\o/"; }' ); 172 $this->assertEquals( $this->wp_customize->get_stylesheet(), get_post( $r )->post_name ); 173 $this->assertEquals( 'body { content: "\o/"; }', get_post( $r )->post_content ); 174 $this->assertEquals( '', get_post( $r )->post_content_filtered ); 175 176 // Make sure that wp_update_custom_css_post() works as expected for insertion. 177 $r = wp_update_custom_css_post( 'body { background:black; }', array( 178 'stylesheet' => 'other', 179 ) ); 180 $this->assertInstanceOf( 'WP_Post', $r ); 181 $this->assertEquals( 'other', get_post( $r )->post_name ); 182 $this->assertEquals( 'body { background:black; }', get_post( $r )->post_content ); 183 $this->assertEquals( 'publish', get_post( $r )->post_status ); 184 185 // Test deletion. 161 186 wp_delete_post( $post_id ); 162 187 $this->assertNull( wp_get_custom_css_post() ); … … 226 251 $original_title = $post->post_title; 227 252 228 add_filter( ' customize_update_custom_css_post_content_args', array( $this, 'filter_update_post_content_args' ), 10, 3 );253 add_filter( 'update_custom_css_data', array( $this, 'filter_update_custom_css_data' ), 10, 3 ); 229 254 $this->setting->save(); 230 255 … … 239 264 * Filter `customize_update_custom_css_post_content_args`. 240 265 * 241 * @param array $args Post array. 242 * @param string $css CSS. 243 * @param WP_Customize_Setting $setting Setting. 244 * @return array Args. 245 */ 246 function filter_update_post_content_args( $args, $css, $setting ) { 266 * @param array $data Data. 267 * @param string $args Args. 268 * @return array Data. 269 */ 270 function filter_update_custom_css_data( $data, $args ) { 271 $this->assertInternalType( 'array', $data ); 272 $this->assertEqualSets( array( 'css', 'preprocessed' ), array_keys( $data ) ); 273 $this->assertEquals( '', $data['preprocessed'] ); 247 274 $this->assertInternalType( 'array', $args ); 248 $this->assertEqualSets( array( 'post_content', 'post_content_filtered' ), array_keys( $args ) ); 249 $this->assertEquals( $css, $args['post_content'] ); 250 $this->assertEquals( '', $args['post_content_filtered'] ); 251 $this->assertInstanceOf( 'WP_Customize_Custom_CSS_Setting', $setting ); 252 253 $args['post_content'] .= '/* filtered post_content */'; 254 $args['post_content_filtered'] = '/* filtered post_content_filtered */'; 255 $args['post_title'] = 'Ignored'; 256 return $args; 275 $this->assertEqualSets( array( 'css', 'preprocessed', 'stylesheet' ), array_keys( $args ) ); 276 $this->assertEquals( $args['css'], $data['css'] ); 277 $this->assertEquals( $args['preprocessed'], $data['preprocessed'] ); 278 279 $data['css'] .= '/* filtered post_content */'; 280 $data['preprocessed'] = '/* filtered post_content_filtered */'; 281 $data['post_title'] = 'Ignored'; 282 return $data; 257 283 } 258 284
Note: See TracChangeset
for help on using the changeset viewer.