Changeset 38830 for trunk/tests/phpunit/tests/customize/manager.php
- Timestamp:
- 10/19/2016 07:38:27 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/manager.php
r38813 r38830 69 69 $_REQUEST = array(); 70 70 parent::tearDown(); 71 } 72 73 /** 74 * Get a core theme that is not the same as the current theme. 75 * 76 * @throws Exception If an inactive core Twenty* theme cannot be found. 77 * @return string Theme slug (stylesheet). 78 */ 79 function get_inactive_core_theme() { 80 $stylesheet = get_stylesheet(); 81 foreach ( wp_get_themes() as $theme ) { 82 if ( $theme->stylesheet !== $stylesheet && 0 === strpos( $theme->stylesheet, 'twenty' ) ) { 83 return $theme->stylesheet; 84 } 85 } 86 throw new Exception( 'Unable to find inactive twenty* theme.' ); 71 87 } 72 88 … … 348 364 */ 349 365 function test_add_state_query_params() { 366 $preview_theme = $this->get_inactive_core_theme(); 367 350 368 $uuid = wp_generate_uuid4(); 351 369 $messenger_channel = 'preview-0'; … … 367 385 'changeset_uuid' => $uuid, 368 386 'messenger_channel' => null, 369 'theme' => 'twentyfifteen',387 'theme' => $preview_theme, 370 388 ) ); 371 389 $url = $wp_customize->add_state_query_params( home_url( '/' ) ); … … 376 394 $this->assertArrayHasKey( 'customize_theme', $query_params ); 377 395 $this->assertEquals( $uuid, $query_params['customize_changeset_uuid'] ); 378 $this->assertEquals( 'twentyfifteen', $query_params['customize_theme'] );396 $this->assertEquals( $preview_theme, $query_params['customize_theme'] ); 379 397 380 398 $uuid = wp_generate_uuid4(); … … 382 400 'changeset_uuid' => $uuid, 383 401 'messenger_channel' => null, 384 'theme' => 'twentyfifteen',402 'theme' => $preview_theme, 385 403 ) ); 386 404 $url = $wp_customize->add_state_query_params( 'http://not-allowed.example.com/?q=1' ); … … 611 629 wp_set_current_user( self::$admin_user_id ); 612 630 631 $preview_theme = $this->get_inactive_core_theme(); 613 632 $stashed_theme_mods = array( 614 'twentyfifteen'=> array(633 $preview_theme => array( 615 634 'background_color' => array( 616 635 'value' => '#123456', … … 622 641 $manager = new WP_Customize_Manager( array( 623 642 'changeset_uuid' => $uuid, 624 'theme' => 'twentyfifteen',643 'theme' => $preview_theme, 625 644 ) ); 626 645 $manager->register_controls(); 627 646 $GLOBALS['wp_customize'] = $manager; 628 647 629 $manager->set_post_value( 'blogname', 'Hello 2015' );648 $manager->set_post_value( 'blogname', 'Hello Preview Theme' ); 630 649 $post_values = $manager->unsanitized_post_values(); 631 650 $manager->save_changeset_post( array( 'status' => 'publish' ) ); // Activate. 632 651 633 652 $this->assertEquals( '#123456', $post_values['background_color'] ); 634 $this->assertEquals( 'twentyfifteen', get_stylesheet() );635 $this->assertEquals( 'Hello 2015', get_option( 'blogname' ) );653 $this->assertEquals( $preview_theme, get_stylesheet() ); 654 $this->assertEquals( 'Hello Preview Theme', get_option( 'blogname' ) ); 636 655 } 637 656 … … 750 769 wp_set_current_user( self::$admin_user_id ); 751 770 771 $preview_theme = $this->get_inactive_core_theme(); 752 772 $stashed_theme_mods = array( 753 'twentyfifteen'=> array(773 $preview_theme => array( 754 774 'background_color' => array( 755 775 'value' => '#000000', … … 828 848 $manager = new WP_Customize_Manager( array( 829 849 'changeset_uuid' => $uuid, 830 'theme' => 'twentyfifteen',850 'theme' => $preview_theme, 831 851 ) ); 832 852 $this->assertFalse( $manager->is_theme_active() );
Note: See TracChangeset
for help on using the changeset viewer.