diff --git a/tests/phpunit/tests/customize/widgets.php b/tests/phpunit/tests/customize/widgets.php index c0836d39e5..310320b18c 100644 --- a/tests/phpunit/tests/customize/widgets.php +++ b/tests/phpunit/tests/customize/widgets.php @@ -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']; diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index 7209f5e69e..d8d1569967 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -33,6 +33,18 @@ CAP; $this->img_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $this->img_name; $this->img_html = ''; $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() {