From 58385f140264e51df9b3ad37ba4c949acd5836ba Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 20 Sep 2020 02:45:35 +0000 Subject: [PATCH] Tests: Skip some image tests if neither GD nor Imagick image editor engines are supported on the system. The explicit message brings some consistency with other image editor tests, specifically the ones using the `WP_Image_UnitTestCase` class. Previously, the tests were marked as "risky" in that scenario, due to performing no assertions. See #50639, #50640. git-svn-id: https://develop.svn.wordpress.org/trunk@49009 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/http/base.php | 2 +- tests/phpunit/tests/image/base.php | 2 +- tests/phpunit/tests/image/functions.php | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php index fdc78ffe3c..4c489140ce 100644 --- a/tests/phpunit/tests/http/base.php +++ b/tests/phpunit/tests/http/base.php @@ -27,7 +27,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $class = 'WP_Http_' . ucfirst( $this->transport ); if ( ! call_user_func( array( $class, 'test' ) ) ) { - $this->markTestSkipped( sprintf( 'The transport %s is not supported on this system', $this->transport ) ); + $this->markTestSkipped( sprintf( 'The transport %s is not supported on this system.', $this->transport ) ); } // Disable all transports aside from this one. diff --git a/tests/phpunit/tests/image/base.php b/tests/phpunit/tests/image/base.php index 8392c548a0..6204709084 100644 --- a/tests/phpunit/tests/image/base.php +++ b/tests/phpunit/tests/image/base.php @@ -12,7 +12,7 @@ abstract class WP_Image_UnitTestCase extends WP_UnitTestCase { parent::setUp(); if ( ! call_user_func( array( $this->editor_engine, 'test' ) ) ) { - $this->markTestSkipped( sprintf( 'The image editor engine %s is not supported on this system', $this->editor_engine ) ); + $this->markTestSkipped( sprintf( 'The image editor engine %s is not supported on this system.', $this->editor_engine ) ); } add_filter( 'wp_image_editors', array( $this, 'setEngine' ), 10, 2 ); diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index 9c81ed6d93..99936c7d00 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -155,6 +155,10 @@ 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() ) { + $this->markTestSkipped( sprintf( 'The image editor engine %s is not supported on this system.', 'WP_Image_Editor_GD' ) ); + } + require_once ABSPATH . 'wp-admin/includes/image-edit.php'; // Mime types. @@ -208,6 +212,10 @@ 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() ) { + $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 ) { @@ -247,6 +255,10 @@ 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() ) { + $this->markTestSkipped( sprintf( 'The image editor engine %s is not supported on this system.', 'WP_Image_Editor_GD' ) ); + } + // Mime types. $mime_types = array( 'jpg' => 'image/jpeg', @@ -307,6 +319,10 @@ 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() ) { + $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 ) { @@ -510,7 +526,6 @@ class Tests_Image_Functions extends WP_UnitTestCase { * @ticket 43226 */ public function test_crop_setting_for_pdf() { - if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) { $this->markTestSkipped( 'Rendering PDFs is not supported on this system.' ); }