diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index 99936c7d00..1daf479360 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -155,7 +155,16 @@ class Tests_Image_Functions extends WP_UnitTestCase { $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' ); } - if ( ! WP_Image_Editor_GD::test() && ! WP_Image_Editor_Imagick::test() ) { + $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); + + foreach ( $classes as $class ) { + if ( ! call_user_func( array( $class, 'test' ) ) ) { + // If the image editor isn't available, skip it. + unset( $classes[ $class ] ); + } + } + + if ( ! $classes ) { $this->markTestSkipped( sprintf( 'The image editor engine %s is not supported on this system.', 'WP_Image_Editor_GD' ) ); } @@ -169,14 +178,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { ); // Test each image editor engine. - $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); foreach ( $classes as $class ) { - - // If the image editor isn't available, skip it. - if ( ! call_user_func( array( $class, 'test' ) ) ) { - continue; - } - $img = new $class( DIR_TESTDATA . '/images/canola.jpg' ); $loaded = $img->load(); @@ -212,19 +214,21 @@ class Tests_Image_Functions extends WP_UnitTestCase { $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' ); } - if ( ! WP_Image_Editor_GD::test() && ! WP_Image_Editor_Imagick::test() ) { + $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); + + foreach ( $classes as $class ) { + if ( ! call_user_func( array( $class, 'test' ) ) ) { + // If the image editor isn't available, skip it. + unset( $classes[ $class ] ); + } + } + + if ( ! $classes ) { $this->markTestSkipped( sprintf( 'The image editor engine %s is not supported on this system.', 'WP_Image_Editor_GD' ) ); } // Test each image editor engine. - $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); foreach ( $classes as $class ) { - - // If the image editor isn't available, skip it. - if ( ! call_user_func( array( $class, 'test' ) ) ) { - continue; - } - $img = new $class( DIR_TESTDATA . '/images/canola.jpg' ); $loaded = $img->load(); @@ -255,7 +259,16 @@ class Tests_Image_Functions extends WP_UnitTestCase { $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' ); } - if ( ! WP_Image_Editor_GD::test() && ! WP_Image_Editor_Imagick::test() ) { + $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); + + foreach ( $classes as $class ) { + if ( ! call_user_func( array( $class, 'test' ) ) ) { + // If the image editor isn't available, skip it. + unset( $classes[ $class ] ); + } + } + + if ( ! $classes ) { $this->markTestSkipped( sprintf( 'The image editor engine %s is not supported on this system.', 'WP_Image_Editor_GD' ) ); } @@ -270,14 +283,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { ); // Test each image editor engine. - $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); foreach ( $classes as $class ) { - - // If the image editor isn't available, skip it. - if ( ! call_user_func( array( $class, 'test' ) ) ) { - continue; - } - $img = new $class( DIR_TESTDATA . '/images/canola.jpg' ); $loaded = $img->load(); @@ -319,18 +325,21 @@ class Tests_Image_Functions extends WP_UnitTestCase { $editor2 = wp_get_image_editor( DIR_TESTDATA ); $this->assertNotInternalType( 'resource', $editor2 ); - if ( ! WP_Image_Editor_GD::test() && ! WP_Image_Editor_Imagick::test() ) { + $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); + + foreach ( $classes as $class ) { + if ( ! call_user_func( array( $class, 'test' ) ) ) { + // If the image editor isn't available, skip it. + unset( $classes[ $class ] ); + } + } + + if ( ! $classes ) { $this->markTestSkipped( sprintf( 'The image editor engine %s is not supported on this system.', 'WP_Image_Editor_GD' ) ); } // Then, test with editors. - $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); foreach ( $classes as $class ) { - // If the image editor isn't available, skip it. - if ( ! call_user_func( array( $class, 'test' ) ) ) { - continue; - } - $editor = new $class( DIR_TESTDATA ); $loaded = $editor->load();