From e878e8156bf268d3fc5f6d84b20ad155b5dbe408 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 22 Aug 2016 04:16:29 +0000 Subject: [PATCH] Media: fix unit test after [38296]. https://en.wikipedia.org/wiki/Coupling_(computer_programming)#Disadvantages Fixes #36246. git-svn-id: https://develop.svn.wordpress.org/trunk@38302 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/media.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index 12e30e6eb7..b1151367fe 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -6,14 +6,20 @@ */ class Tests_Media extends WP_UnitTestCase { protected static $large_id; + protected static $_sizes; public static function wpSetUpBeforeClass( $factory ) { + self::$_sizes = $GLOBALS['_wp_additional_image_sizes']; + $GLOBALS['_wp_additional_image_sizes'] = array(); + $filename = DIR_TESTDATA . '/images/test-image-large.png'; self::$large_id = $factory->attachment->create_upload_object( $filename ); } public static function wpTearDownAfterClass() { wp_delete_attachment( self::$large_id ); + + $GLOBALS['_wp_additional_image_sizes'] = self::$_sizes; } function setUp() { @@ -1770,8 +1776,17 @@ EOF; function test_wp_get_attachment_image_should_use_wp_get_attachment_metadata() { add_filter( 'wp_get_attachment_metadata', array( $this, '_filter_36246' ), 10, 2 ); + remove_all_filters( 'wp_calculate_image_sizes' ); + $actual = wp_get_attachment_image( self::$large_id, 'testsize' ); - $expected = 'test-image-large.png'; + $year = date( 'Y' ); + $month = date( 'm' ); + + $expected = 'test-image-large.png'; remove_filter( 'wp_get_attachment_metadata', array( $this, '_filter_36246' ) );