Changeset 42343 for trunk/tests/phpunit/tests/customize/partial.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/customize/partial.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/partial.php
r38858 r42343 49 49 function test_construct_default_args() { 50 50 $partial_id = 'blogname'; 51 $partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id );51 $partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id ); 52 52 $this->assertEquals( $partial_id, $partial->id ); 53 53 $this->assertEquals( $this->selective_refresh, $partial->component ); … … 87 87 function test_construct_non_default_args() { 88 88 89 $post_id = self::factory()->post->create( array( 90 'post_title' => 'Hello World', 91 'post_content' => 'Lorem Ipsum', 92 ) ); 89 $post_id = self::factory()->post->create( 90 array( 91 'post_title' => 'Hello World', 92 'post_content' => 'Lorem Ipsum', 93 ) 94 ); 93 95 94 96 $partial_id = sprintf( 'post_content[%d]', $post_id ); 95 $args = array(96 'type' => 'post',97 'selector' => "article.post-$post_id .entry-content",98 'settings' => array( 'user[1]', "post[$post_id]" ),99 'primary_setting' => "post[$post_id]",100 'render_callback' => array( $this, 'render_post_content_partial' ),97 $args = array( 98 'type' => 'post', 99 'selector' => "article.post-$post_id .entry-content", 100 'settings' => array( 'user[1]', "post[$post_id]" ), 101 'primary_setting' => "post[$post_id]", 102 'render_callback' => array( $this, 'render_post_content_partial' ), 101 103 'container_inclusive' => false, 102 'fallback_refresh' => false,103 ); 104 $partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id, $args );104 'fallback_refresh' => false, 105 ); 106 $partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id, $args ); 105 107 $this->assertEquals( $partial_id, $partial->id ); 106 108 $this->assertEquals( $this->selective_refresh, $partial->component ); … … 114 116 $this->assertContains( 'Lorem Ipsum', $partial->render() ); 115 117 116 $partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id, array( 117 'settings' => 'blogdescription', 118 ) ); 118 $partial = new WP_Customize_Partial( 119 $this->selective_refresh, $partial_id, array( 120 'settings' => 'blogdescription', 121 ) 122 ); 119 123 $this->assertEquals( array( 'blogdescription' ), $partial->settings ); 120 124 $this->assertEquals( 'blogdescription', $partial->primary_setting ); … … 217 221 */ 218 222 function test_render_with_bad_callback_should_give_preference_to_return_value() { 219 $partial = new WP_Customize_Partial( $this->selective_refresh, 'foo', array( 220 'render_callback' => array( $this, 'render_echo_and_return' ), 221 ) ); 223 $partial = new WP_Customize_Partial( 224 $this->selective_refresh, 'foo', array( 225 'render_callback' => array( $this, 'render_echo_and_return' ), 226 ) 227 ); 222 228 $this->setExpectedIncorrectUsage( 'render' ); 223 229 $this->assertSame( 'bar', $partial->render() ); … … 230 236 */ 231 237 function test_render_echo_callback() { 232 $partial = new WP_Customize_Partial( $this->selective_refresh, 'foo', array( 233 'render_callback' => array( $this, 'render_echo' ), 234 ) ); 235 $count_filter_customize_partial_render = $this->count_filter_customize_partial_render; 238 $partial = new WP_Customize_Partial( 239 $this->selective_refresh, 'foo', array( 240 'render_callback' => array( $this, 'render_echo' ), 241 ) 242 ); 243 $count_filter_customize_partial_render = $this->count_filter_customize_partial_render; 236 244 $count_filter_customize_partial_render_with_id = $this->count_filter_customize_partial_render_with_id; 237 245 add_filter( 'customize_partial_render', array( $this, 'filter_customize_partial_render' ), 10, 3 ); … … 249 257 */ 250 258 function test_render_return_callback() { 251 $partial = new WP_Customize_Partial( $this->selective_refresh, 'foo', array( 252 'render_callback' => array( $this, 'render_return' ), 253 ) ); 254 $count_filter_customize_partial_render = $this->count_filter_customize_partial_render; 259 $partial = new WP_Customize_Partial( 260 $this->selective_refresh, 'foo', array( 261 'render_callback' => array( $this, 'render_return' ), 262 ) 263 ); 264 $count_filter_customize_partial_render = $this->count_filter_customize_partial_render; 255 265 $count_filter_customize_partial_render_with_id = $this->count_filter_customize_partial_render_with_id; 256 266 add_filter( 'customize_partial_render', array( $this, 'filter_customize_partial_render' ), 10, 3 ); … … 279 289 */ 280 290 function test_json() { 281 $post_id = 123;291 $post_id = 123; 282 292 $partial_id = sprintf( 'post_content[%d]', $post_id ); 283 $args = array(284 'type' => 'post',285 'selector' => "article.post-$post_id .entry-content",286 'settings' => array( 'user[1]', "post[$post_id]" ),287 'primary_setting' => "post[$post_id]",288 'render_callback' => array( $this, 'render_post_content_partial' ),293 $args = array( 294 'type' => 'post', 295 'selector' => "article.post-$post_id .entry-content", 296 'settings' => array( 'user[1]', "post[$post_id]" ), 297 'primary_setting' => "post[$post_id]", 298 'render_callback' => array( $this, 'render_post_content_partial' ), 289 299 'container_inclusive' => false, 290 'fallback_refresh' => false,291 ); 292 $partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id, $args );300 'fallback_refresh' => false, 301 ); 302 $partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id, $args ); 293 303 294 304 $exported = $partial->json(); … … 309 319 wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); 310 320 do_action( 'customize_register', $this->wp_customize ); 311 $partial = new WP_Customize_Partial( $this->selective_refresh, 'blogname', array( 312 'settings' => array( 'blogname' ), 313 ) ); 321 $partial = new WP_Customize_Partial( 322 $this->selective_refresh, 'blogname', array( 323 'settings' => array( 'blogname' ), 324 ) 325 ); 314 326 $this->assertTrue( $partial->check_capabilities() ); 315 327 316 $partial = new WP_Customize_Partial( $this->selective_refresh, 'blogname', array( 317 'settings' => array( 'blogname', 'non_existing' ), 318 ) ); 328 $partial = new WP_Customize_Partial( 329 $this->selective_refresh, 'blogname', array( 330 'settings' => array( 'blogname', 'non_existing' ), 331 ) 332 ); 319 333 $this->assertFalse( $partial->check_capabilities() ); 320 334 321 $this->wp_customize->add_setting( 'top_secret_message', array( 322 'capability' => 'top_secret_clearance', 323 ) ); 324 $partial = new WP_Customize_Partial( $this->selective_refresh, 'blogname', array( 325 'settings' => array( 'blogname', 'top_secret_clearance' ), 326 ) ); 335 $this->wp_customize->add_setting( 336 'top_secret_message', array( 337 'capability' => 'top_secret_clearance', 338 ) 339 ); 340 $partial = new WP_Customize_Partial( 341 $this->selective_refresh, 'blogname', array( 342 'settings' => array( 'blogname', 'top_secret_clearance' ), 343 ) 344 ); 327 345 $this->assertFalse( $partial->check_capabilities() ); 328 346 329 $partial = new WP_Customize_Partial( $this->selective_refresh, 'no_setting', array( 330 'settings' => array(), 331 ) ); 347 $partial = new WP_Customize_Partial( 348 $this->selective_refresh, 'no_setting', array( 349 'settings' => array(), 350 ) 351 ); 332 352 $this->assertTrue( $partial->check_capabilities() ); 333 353 334 $partial = new WP_Customize_Partial( $this->selective_refresh, 'no_setting', array( 335 'settings' => array(), 336 'capability' => 'top_secret_clearance', 337 ) ); 354 $partial = new WP_Customize_Partial( 355 $this->selective_refresh, 'no_setting', array( 356 'settings' => array(), 357 'capability' => 'top_secret_clearance', 358 ) 359 ); 338 360 $this->assertFalse( $partial->check_capabilities() ); 339 361 340 $partial = new WP_Customize_Partial( $this->selective_refresh, 'no_setting', array( 341 'settings' => array(), 342 'capability' => 'edit_theme_options', 343 ) ); 362 $partial = new WP_Customize_Partial( 363 $this->selective_refresh, 'no_setting', array( 364 'settings' => array(), 365 'capability' => 'edit_theme_options', 366 ) 367 ); 344 368 $this->assertTrue( $partial->check_capabilities() ); 345 369 }
Note: See TracChangeset
for help on using the changeset viewer.