Tests: Prevent Twenty Seventeen from interfering with Customizer tests.

This was previously fixed in [38837], but it wasn't really the correct answer, to fix it in the theme. So, [38837] is reverted in this commit, and the Twenty Seventeen actions causing problems are unhooked before tests are run.

See #38372.



git-svn-id: https://develop.svn.wordpress.org/trunk@38850 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2016-10-21 05:27:56 +00:00
parent a8aa7b0ca2
commit 90f8c9314a
10 changed files with 28 additions and 7 deletions

View File

@ -13,13 +13,9 @@
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function twentyseventeen_customize_register( $wp_customize ) {
$postMessage_settings = array( 'blogname', 'blogdescription', 'header_textcolor' );
foreach( $postMessage_settings as $postMessage_setting ) {
$setting = $wp_customize->get_setting( $postMessage_setting );
if ( $setting ) {
$setting->transport = 'postMessage';
}
}
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
/**
* Custom colors.

View File

@ -31,6 +31,9 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
// @codingStandardsIgnoreEnd
$this->wp_customize = $GLOBALS['wp_customize'];
// Remove default theme actions that interfere with tests
remove_action( 'customize_register', 'twentyseventeen_customize_register' );
}
/**

View File

@ -36,6 +36,9 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
$this->wp_customize = new WP_Customize_Manager();
$wp_customize = $this->wp_customize;
// Remove default theme actions that interfere with tests
remove_action( 'customize_register', 'twentyseventeen_customize_register' );
do_action( 'customize_register', $this->wp_customize );
$this->setting = new WP_Customize_Custom_CSS_Setting( $this->wp_customize, 'custom_css[twentysixteen]' );
$this->wp_customize->add_setting( $this->setting );

View File

@ -58,6 +58,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
require_once( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
$this->manager = $this->instantiate();
$this->undefined = new stdClass();
// Remove default theme actions that interfere with tests
remove_action( 'customize_register', 'twentyseventeen_customize_register' );
}
/**

View File

@ -26,6 +26,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
global $wp_customize;
$this->wp_customize = new WP_Customize_Manager();
$wp_customize = $this->wp_customize;
// Remove default theme actions that interfere with tests
remove_action( 'customize_register', 'twentyseventeen_customize_register' );
}
/**

View File

@ -27,6 +27,9 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
global $wp_customize;
$this->wp_customize = new WP_Customize_Manager();
$wp_customize = $this->wp_customize;
// Remove default theme actions that interfere with tests
remove_action( 'customize_register', 'twentyseventeen_customize_register' );
}
/**

View File

@ -26,6 +26,9 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
global $wp_customize;
$this->wp_customize = new WP_Customize_Manager();
$wp_customize = $this->wp_customize;
// Remove default theme actions that interfere with tests
remove_action( 'customize_register', 'twentyseventeen_customize_register' );
}
/**

View File

@ -39,6 +39,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
if ( isset( $this->wp_customize->selective_refresh ) ) {
$this->selective_refresh = $this->wp_customize->selective_refresh;
}
// Remove default theme actions that interfere with tests
remove_action( 'customize_register', 'twentyseventeen_customize_register' );
}
/**

View File

@ -39,6 +39,9 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
if ( isset( $this->wp_customize->selective_refresh ) ) {
$this->selective_refresh = $this->wp_customize->selective_refresh;
}
// Remove default theme actions that interfere with tests
remove_action( 'customize_register', 'twentyseventeen_customize_register' );
}
/**

View File

@ -45,6 +45,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
remove_action( 'after_setup_theme', 'twentysixteen_setup' );
remove_action( 'customize_register', 'twentysixteen_customize_register', 11 );
remove_action( 'after_setup_theme', 'twentyseventeen_setup' );
remove_action( 'customize_register', 'twentyseventeen_customize_register' );
$this->backup_registered_sidebars = $GLOBALS['wp_registered_sidebars'];