Changeset 39346 for trunk/tests/phpunit/tests/customize/manager.php
- Timestamp:
- 11/23/2016 09:52:27 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/manager.php
r39332 r39346 314 314 function test_import_theme_starter_content() { 315 315 wp_set_current_user( self::$admin_user_id ); 316 register_nav_menu( 'top', 'Top' ); 316 317 317 318 global $wp_customize; … … 344 345 'posts' => array( 345 346 'home', 346 'about', 347 'about' => array( 348 'template' => 'sample-page-template.php', 349 ), 347 350 'blog', 348 351 'custom' => array( 349 352 'post_type' => 'post', 350 353 'post_title' => 'Custom', 354 'thumbnail' => '{{featured-image-logo}}', 355 ), 356 ), 357 'attachments' => array( 358 'featured-image-logo' => array( 359 'post_title' => 'Featured Image', 360 'post_content' => 'Attachment Description', 361 'post_excerpt' => 'Attachment Caption', 362 'file' => DIR_TESTDATA . '/images/waffles.jpg', 351 363 ), 352 364 ), … … 395 407 396 408 $posts_by_name = array(); 409 $this->assertCount( 5, $changeset_values['nav_menus_created_posts'] ); 397 410 foreach ( $changeset_values['nav_menus_created_posts'] as $post_id ) { 398 411 $post = get_post( $post_id ); … … 400 413 $posts_by_name[ $post->post_name ] = $post->ID; 401 414 } 415 $this->assertEquals( array( 'featured-image', 'home', 'about', 'blog', 'custom' ), array_keys( $posts_by_name ) ); 416 $this->assertEquals( 'Custom', get_post( $posts_by_name['custom'] )->post_title ); 417 $this->assertEquals( 'sample-page-template.php', get_page_template_slug( $posts_by_name['about'] ) ); 418 $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'] ) ); 420 $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 ); 423 $this->assertArrayHasKey( 'file', $attachment_metadata ); 424 $this->assertContains( 'waffles', $attachment_metadata['file'] ); 402 425 403 426 $this->assertEquals( 'page', $changeset_values['show_on_front'] ); … … 419 442 } 420 443 444 // Ensure that re-importing doesn't cause auto-drafts to balloon. 445 $wp_customize->import_theme_starter_content(); 446 $changeset_data = $wp_customize->changeset_data(); 447 $this->assertEqualSets( array_values( $posts_by_name ), $changeset_data['nav_menus_created_posts']['value'], 'Auto-drafts should not get re-created and amended with each import.' ); 448 421 449 // Test that saving non-starter content on top of the changeset clears the starter_content flag. 422 450 $wp_customize->save_changeset_post( array( … … 443 471 $this->assertNotEquals( $previous_blogdescription, $changeset_data['blogdescription']['value'] ); 444 472 $this->assertArrayHasKey( 'starter_content', $changeset_data['blogdescription'] ); 473 474 // Publish. 475 $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 ); 477 $this->assertNotEquals( $changeset_data['blogname']['value'], get_option( 'blogname' ) ); 478 $r = $wp_customize->save_changeset_post( array( 'status' => 'publish' ) ); 479 $this->assertInternalType( 'array', $r ); 480 $this->assertEquals( 'publish', get_post( $posts_by_name['about'] )->post_status ); 481 $this->assertEquals( 'inherit', get_post( $posts_by_name['featured-image'] )->post_status ); 482 $this->assertEquals( $changeset_data['blogname']['value'], get_option( 'blogname' ) ); 445 483 } 446 484
Note: See TracChangeset
for help on using the changeset viewer.