Changeset 39412 for branches/4.7/tests/phpunit/tests/customize/manager.php
- Timestamp:
- 12/02/2016 12:25:47 AM (8 years ago)
- Location:
- branches/4.7
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7
-
branches/4.7/tests/phpunit/tests/customize/manager.php
r39410 r39412 315 315 wp_set_current_user( self::$admin_user_id ); 316 316 register_nav_menu( 'top', 'Top' ); 317 add_theme_support( 'custom-logo' ); 318 add_theme_support( 'custom-header' ); 319 add_theme_support( 'custom-background' ); 320 321 $canola_file = DIR_TESTDATA . '/images/canola.jpg'; 322 $existing_canola_attachment_id = self::factory()->attachment->create_object( $canola_file, 0, array( 323 'post_mime_type' => 'image/jpeg', 324 'post_type' => 'attachment', 325 'post_name' => 'canola', 326 ) ); 327 $existing_published_home_page_id = $this->factory()->post->create( array( 328 'post_name' => 'home', 329 'post_type' => 'page', 330 'post_status' => 'publish' 331 ) ); 332 $existing_auto_draft_about_page_id = $this->factory()->post->create( array( 333 'post_name' => 'about', 334 'post_type' => 'page', 335 'post_status' => 'auto-draft' 336 ) ); 317 337 318 338 global $wp_customize; … … 352 372 'post_type' => 'post', 353 373 'post_title' => 'Custom', 354 'thumbnail' => '{{ featured-image-logo}}',374 'thumbnail' => '{{waffles}}', 355 375 ), 356 376 ), 357 377 'attachments' => array( 358 ' featured-image-logo' => array(359 'post_title' => ' Featured Image',360 'post_content' => ' Attachment Description',361 'post_excerpt' => ' Attachment Caption',378 'waffles' => array( 379 'post_title' => 'Waffles', 380 'post_content' => 'Waffles Attachment Description', 381 'post_excerpt' => 'Waffles Attachment Caption', 362 382 'file' => DIR_TESTDATA . '/images/waffles.jpg', 383 ), 384 'canola' => array( 385 'post_title' => 'Canola', 386 'post_content' => 'Canola Attachment Description', 387 'post_excerpt' => 'Canola Attachment Caption', 388 'file' => DIR_TESTDATA . '/images/canola.jpg', 363 389 ), 364 390 ), … … 369 395 'page_on_front' => '{{home}}', 370 396 'page_for_posts' => '{{blog}}', 397 ), 398 'theme_mods' => array( 399 'custom_logo' => '{{canola}}', 400 'header_image' => '{{waffles}}', 401 'background_image' => '{{waffles}}', 371 402 ), 372 403 ); … … 379 410 'blogname', 380 411 'blogdescription', 412 'custom_logo', 413 'header_image_data', 414 'background_image', 381 415 'widget_text[2]', 382 416 'widget_meta[3]', … … 407 441 408 442 $posts_by_name = array(); 409 $this->assertCount( 5, $changeset_values['nav_menus_created_posts'] ); 443 $this->assertCount( 6, $changeset_values['nav_menus_created_posts'] ); 444 $this->assertContains( $existing_published_home_page_id, $changeset_values['nav_menus_created_posts'], 'Expected reuse of non-auto-draft posts.' ); 445 $this->assertContains( $existing_canola_attachment_id, $changeset_values['nav_menus_created_posts'], 'Expected reuse of non-auto-draft attachment.' ); 446 $this->assertNotContains( $existing_auto_draft_about_page_id, $changeset_values['nav_menus_created_posts'], 'Expected non-reuse of auto-draft posts.' ); 410 447 foreach ( $changeset_values['nav_menus_created_posts'] as $post_id ) { 411 448 $post = get_post( $post_id ); 412 $this->assertEquals( 'auto-draft', $post->post_status ); 449 if ( $post->ID === $existing_published_home_page_id ) { 450 $this->assertEquals( 'publish', $post->post_status ); 451 } elseif ( $post->ID === $existing_canola_attachment_id ) { 452 $this->assertEquals( 'inherit', $post->post_status ); 453 } else { 454 $this->assertEquals( 'auto-draft', $post->post_status ); 455 } 413 456 $posts_by_name[ $post->post_name ] = $post->ID; 414 457 } 415 $this->assertEquals( array( ' featured-image', 'home', 'about', 'blog', 'custom' ), array_keys( $posts_by_name ) );458 $this->assertEquals( array( 'waffles', 'canola', 'home', 'about', 'blog', 'custom' ), array_keys( $posts_by_name ) ); 416 459 $this->assertEquals( 'Custom', get_post( $posts_by_name['custom'] )->post_title ); 417 460 $this->assertEquals( 'sample-page-template.php', get_page_template_slug( $posts_by_name['about'] ) ); 418 461 $this->assertEquals( '', get_page_template_slug( $posts_by_name['blog'] ) ); 419 $this->assertEquals( $posts_by_name[' featured-image'], get_post_thumbnail_id( $posts_by_name['custom'] ) );462 $this->assertEquals( $posts_by_name['waffles'], get_post_thumbnail_id( $posts_by_name['custom'] ) ); 420 463 $this->assertEquals( '', get_post_thumbnail_id( $posts_by_name['blog'] ) ); 421 $attachment_metadata = wp_get_attachment_metadata( $posts_by_name[' featured-image'] );422 $this->assertEquals( ' Featured Image', get_post( $posts_by_name['featured-image'] )->post_title );464 $attachment_metadata = wp_get_attachment_metadata( $posts_by_name['waffles'] ); 465 $this->assertEquals( 'Waffles', get_post( $posts_by_name['waffles'] )->post_title ); 423 466 $this->assertArrayHasKey( 'file', $attachment_metadata ); 424 467 $this->assertContains( 'waffles', $attachment_metadata['file'] ); … … 473 516 474 517 // Publish. 518 $this->assertEmpty( get_custom_logo() ); 519 $this->assertEmpty( get_header_image() ); 520 $this->assertEmpty( get_background_image() ); 521 $this->assertEmpty( get_theme_mod( 'custom_logo' ) ); 522 $this->assertEmpty( get_theme_mod( 'header_image' ) ); 523 $this->assertEmpty( get_theme_mod( 'background_image' ) ); 475 524 $this->assertEquals( 'auto-draft', get_post( $posts_by_name['about'] )->post_status ); 476 $this->assertEquals( 'auto-draft', get_post( $posts_by_name[' featured-image'] )->post_status );525 $this->assertEquals( 'auto-draft', get_post( $posts_by_name['waffles'] )->post_status ); 477 526 $this->assertNotEquals( $changeset_data['blogname']['value'], get_option( 'blogname' ) ); 478 527 $r = $wp_customize->save_changeset_post( array( 'status' => 'publish' ) ); 479 528 $this->assertInternalType( 'array', $r ); 480 529 $this->assertEquals( 'publish', get_post( $posts_by_name['about'] )->post_status ); 481 $this->assertEquals( 'inherit', get_post( $posts_by_name[' featured-image'] )->post_status );530 $this->assertEquals( 'inherit', get_post( $posts_by_name['waffles'] )->post_status ); 482 531 $this->assertEquals( $changeset_data['blogname']['value'], get_option( 'blogname' ) ); 532 $this->assertNotEmpty( get_theme_mod( 'custom_logo' ) ); 533 $this->assertNotEmpty( get_theme_mod( 'header_image' ) ); 534 $this->assertNotEmpty( get_theme_mod( 'background_image' ) ); 535 $this->assertNotEmpty( get_custom_logo() ); 536 $this->assertNotEmpty( get_header_image() ); 537 $this->assertNotEmpty( get_background_image() ); 538 $this->assertContains( 'canola', get_custom_logo() ); 539 $this->assertContains( 'waffles', get_header_image() ); 540 $this->assertContains( 'waffles', get_background_image() ); 483 541 } 484 542
Note: See TracChangeset
for help on using the changeset viewer.