diff --git a/tests/phpunit/includes/mock-image-editor.php b/tests/phpunit/includes/mock-image-editor.php index 2d8164e5c9..808b32dfc3 100644 --- a/tests/phpunit/includes/mock-image-editor.php +++ b/tests/phpunit/includes/mock-image-editor.php @@ -11,7 +11,7 @@ if (class_exists( 'WP_Image_Editor' ) ) : public function load() { return self::$load_return; } - public static function test() { + public static function test( $args = array() ) { return self::$test_return; } public static function supports_mime_type( $mime_type ) { diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index 3982f7bc5a..2b5b1d7245 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -9,12 +9,30 @@ class Tests_Image_Functions extends WP_UnitTestCase { /** * Setup test fixture */ - public function setup() { + public function setUp() { + parent::setUp(); + require_once( ABSPATH . WPINC . '/class-wp-image-editor.php' ); require_once( ABSPATH . WPINC . '/class-wp-image-editor-gd.php' ); require_once( ABSPATH . WPINC . '/class-wp-image-editor-imagick.php' ); include_once( DIR_TESTDATA . '/../includes/mock-image-editor.php' ); + add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) ); + } + + function tearDown() { + parent::tearDown(); + remove_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ) ); + } + + function deprecated_function_run( $function ) { + if ( in_array( $function, array( 'wp_load_image' ) ) ) + add_filter( 'deprecated_function_trigger_error', array( $this, 'deprecated_function_trigger_error' ) ); + } + + function deprecated_function_trigger_error() { + remove_filter( 'deprecated_function_trigger_error', array( $this, 'deprecated_function_trigger_error' ) ); + return false; } /** @@ -236,8 +254,11 @@ class Tests_Image_Functions extends WP_UnitTestCase { public function test_load_directory() { // First, test with deprecated wp_load_image function - $editor = wp_load_image( DIR_TESTDATA ); - $this->assertNotInternalType( 'resource', $editor ); + $editor1 = wp_load_image( DIR_TESTDATA ); + $this->assertNotInternalType( 'resource', $editor1 ); + + $editor2 = wp_get_image_editor( DIR_TESTDATA ); + $this->assertNotInternalType( 'resource', $editor2 ); // Then, test with editors. $classes = array('WP_Image_Editor_GD', 'WP_Image_Editor_Imagick');