Tests: Fix tests that don't pass when Twenty Seventeen is the default theme.

There are some tests who's outcome can be affected by the default theme, so we need to ensure the Twenty Seventeen functionality is unhooked while the tests are running.

See #38372.



git-svn-id: https://develop.svn.wordpress.org/trunk@38838 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2016-10-20 09:06:11 +00:00
parent 420b6af50a
commit b0e625bfdf
2 changed files with 20 additions and 1 deletions

View File

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

View File

@ -33,6 +33,18 @@ CAP;
$this->img_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $this->img_name;
$this->img_html = '<img src="' . $this->img_url . '"/>';
$this->img_meta = array( 'width' => 100, 'height' => 100, 'sizes' => '' );
// Disable Twenty Seventeen changes to the image size attribute
remove_filter( 'wp_calculate_image_sizes', 'twentyseventeen_content_image_sizes_attr' );
remove_filter( 'wp_get_attachment_image_attributes', 'twentyseventeen_post_thumbnail_sizes_attr' );
}
function tearDown() {
parent::tearDown();
// Reset Twenty Seventeen behaviour
add_filter( 'wp_calculate_image_sizes', 'twentyseventeen_content_image_sizes_attr', 10, 2 );
add_filter( 'wp_get_attachment_image_attributes', 'twentyseventeen_post_thumbnail_sizes_attr', 10, 3 );
}
function test_img_caption_shortcode_added() {
@ -55,10 +67,16 @@ CAP;
$result = img_caption_shortcode(
array( 'width' => 20, 'caption' => $this->caption )
);
$this->assertEquals( 2, preg_match_all( '/wp-caption/', $result, $_r ) );
$this->assertEquals( 1, preg_match_all( '/alignnone/', $result, $_r ) );
$this->assertEquals( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) );
$this->assertEquals( 1, preg_match_all( "/width: 30/", $result, $_r ) );
if ( current_theme_supports( 'html5', 'caption' ) ) {
$this->assertEquals( 1, preg_match_all( "/width: 20/", $result, $_r ) );
} else {
$this->assertEquals( 1, preg_match_all( "/width: 30/", $result, $_r ) );
}
}
function test_img_caption_shortcode_with_old_format_id_and_align() {