Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Add test for Customize_Snapshot_Manager::import_snapshot_data()
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Aug 11, 2016
1 parent f825bea commit 4ea308b
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions tests/php/test-class-customize-snapshot-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@ public function test_is_previewing_settings_via_preview_init() {
/**
* Tests preview_snapshot_settings.
*
* @covers CustomizeSnapshots\Customize_Snapshot_Manager::init()
* @covers CustomizeSnapshots\Customize_Snapshot_Manager::preview_snapshot_settings()
*/
public function test_preview_snapshot_settings() {
Expand All @@ -481,7 +480,6 @@ public function test_preview_snapshot_settings() {
$manager->init();
$manager->ensure_customize_manager();
do_action( 'customize_register', $manager->customize_manager );
$manager->customize_manager->set_post_value( 'blogname', 'Hello' );
$this->assertFalse( $manager->is_previewing_settings() );
$this->assertFalse( $manager->customize_manager->get_setting( 'blogname' )->dirty );
$this->assertNotEquals( 'Hello', get_option( 'blogname' ) );
Expand All @@ -496,7 +494,34 @@ public function test_preview_snapshot_settings() {
* @covers CustomizeSnapshots\Customize_Snapshot_Manager::import_snapshot_data()
*/
public function test_import_snapshot_data() {
$this->markTestIncomplete();
global $wp_actions;
$_REQUEST['customize_snapshot_uuid'] = self::UUID;
$this->manager->post_type->save( array(
'uuid' => self::UUID,
'data' => array(
'blogname' => array( 'value' => 'Hello' ),
'blogdescription' => array( 'value' => null ),
),
'status' => 'draft',
) );

// Prevent init from calling import_snapshot_data straight away.
unset( $wp_actions['setup_theme'] );

$manager = new Customize_Snapshot_Manager( $this->plugin );
$manager->init();
$manager->ensure_customize_manager();
do_action( 'customize_register', $manager->customize_manager );

$this->assertArrayNotHasKey( 'customized', $_POST );
$this->assertArrayNotHasKey( 'customized', $_REQUEST );
$this->assertArrayNotHasKey( 'blogname', $manager->customize_manager->unsanitized_post_values() );
$this->assertArrayNotHasKey( 'blogdescription', $manager->customize_manager->unsanitized_post_values() );
$manager->import_snapshot_data();
$this->assertArrayHasKey( 'customized', $_POST );
$this->assertArrayHasKey( 'customized', $_REQUEST );
$this->assertArrayHasKey( 'blogname', $manager->customize_manager->unsanitized_post_values() );
$this->assertArrayNotHasKey( 'blogdescription', $manager->customize_manager->unsanitized_post_values() );
}

/**
Expand Down

0 comments on commit 4ea308b

Please sign in to comment.