Changeset 39180 for trunk/tests/phpunit/tests/customize/manager.php
- Timestamp:
- 11/09/2016 05:44:14 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/manager.php
r39140 r39180 417 417 */ 418 418 function test_save_changeset_post_without_theme_activation() { 419 global $wp_customize; 419 420 wp_set_current_user( self::$admin_user_id ); 420 421 … … 426 427 $uuid = wp_generate_uuid4(); 427 428 428 $ manager = new WP_Customize_Manager( array(429 $wp_customize = $manager = new WP_Customize_Manager( array( 429 430 'changeset_uuid' => $uuid, 430 431 ) ); … … 508 509 509 510 // Attempt a non-transactional/incremental update. 510 $ manager = new WP_Customize_Manager( array(511 $wp_customize = $manager = new WP_Customize_Manager( array( 511 512 'changeset_uuid' => $uuid, 512 513 ) ); … … 544 545 $this->assertEquals( $customize_changeset_save_data_call_count + 1, $this->customize_changeset_save_data_call_count ); 545 546 546 // Publish the changeset. 547 $manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) ); 547 // Publish the changeset: actions will be doubled since also trashed. 548 $expected_actions = array( 549 'wp_trash_post' => 1, 550 'clean_post_cache' => 2, 551 'transition_post_status' => 2, 552 'publish_to_trash' => 1, 553 'trash_customize_changeset' => 1, 554 'edit_post' => 2, 555 'save_post_customize_changeset' => 2, 556 'save_post' => 2, 557 'wp_insert_post' => 2, 558 'trashed_post' => 1, 559 ); 560 $action_counts = array(); 561 foreach ( array_keys( $expected_actions ) as $action_name ) { 562 $action_counts[ $action_name ] = did_action( $action_name ); 563 } 564 565 $wp_customize = $manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) ); 548 566 $manager->register_controls(); 549 $GLOBALS['wp_customize'] = $manager; 567 $manager->add_setting( 'scratchpad', array( 568 'type' => 'option', 569 'capability' => 'exist', 570 ) ); 571 $manager->get_setting( 'blogname' )->capability = 'exist'; 572 wp_set_current_user( self::$subscriber_user_id ); 550 573 $r = $manager->save_changeset_post( array( 551 574 'status' => 'publish', … … 554 577 'value' => 'Do it live \o/', 555 578 ), 579 'scratchpad' => array( 580 'value' => '<script>console.info( "HELLO" )</script>', 581 ), 556 582 ), 557 583 ) ); … … 559 585 $this->assertEquals( 'Do it live \o/', get_option( 'blogname' ) ); 560 586 $this->assertEquals( 'trash', get_post_status( $post_id ) ); // Auto-trashed. 587 $this->assertContains( '<script>', get_post( $post_id )->post_content ); 588 $this->assertEquals( $manager->changeset_uuid(), get_post( $post_id )->post_name, 'Expected that the "__trashed" suffix to not be added.' ); 589 wp_set_current_user( self::$admin_user_id ); 590 $this->assertEquals( 'publish', get_post_meta( $post_id, '_wp_trash_meta_status', true ) ); 591 $this->assertTrue( is_numeric( get_post_meta( $post_id, '_wp_trash_meta_time', true ) ) ); 592 593 foreach ( array_keys( $expected_actions ) as $action_name ) { 594 $this->assertEquals( $expected_actions[ $action_name ] + $action_counts[ $action_name ], did_action( $action_name ), "Action: $action_name" ); 595 } 561 596 562 597 // Test revisions. 563 598 add_post_type_support( 'customize_changeset', 'revisions' ); 564 599 $uuid = wp_generate_uuid4(); 565 $ manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );600 $wp_customize = $manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) ); 566 601 $manager->register_controls(); 567 $GLOBALS['wp_customize'] = $manager;568 602 569 603 $manager->set_post_value( 'blogname', 'Hello Surface' );
Note: See TracChangeset
for help on using the changeset viewer.