Skip to content

Commit

Permalink
Tweak unit tests to work with changesets
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Oct 7, 2016
1 parent ca32e22 commit 78c2c6b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions php/class-wp-customize-widget-setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ public function apply_preview() {
if ( ! is_null( $value ) ) {
$this->widget_posts->current_widget_type_values[ $this->widget_id_base ][ $this->widget_number ] = $value;
}

add_action( "customize_post_value_set_{$this->id}", array( $this, '_update_current_widget_type_value' ) );
}

/**
* Make sure that the cached widget preview value is updated when the post value is updated.
*
* @access private
*/
function _update_current_widget_type_value() {
$value = $this->post_value();
if ( ! is_null( $value ) ) {
$this->widget_posts->current_widget_type_values[ $this->widget_id_base ][ $this->widget_number ] = $value;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/test-class-widget-posts-with-customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function setUp() {
global $wp_registered_widgets;
$wp_registered_widgets = array();
wp_widgets_init();
do_action( 'wp_loaded' );
}

/**
Expand Down Expand Up @@ -88,6 +87,7 @@ function test_customize_widgets_save() {
);
$sanitized_widget_instance = $this->customize_manager->widgets->sanitize_widget_js_instance( $override_widget_data );
$this->customize_manager->set_post_value( $setting_id, $sanitized_widget_instance );
$this->customize_manager->add_dynamic_settings( array( $setting_id ) );

$widget_post = $this->widget_posts->get_widget_post( $widget_id );
$this->assertEquals( $initial_search_widgets[2], $this->widget_posts->get_widget_instance_data( $widget_post ) );
Expand Down

0 comments on commit 78c2c6b

Please sign in to comment.