Tests: Optimize some image tests to avoid checking for image editor engines availability twice.
Follow-up to [49009]. See #50639, #50640. git-svn-id: https://develop.svn.wordpress.org/trunk@49014 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
42019042de
commit
68b71263f3
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user