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
This commit is contained in:
Sergey Biryukov 2020-09-20 02:45:35 +00:00
parent 2bfa83d882
commit 58385f1402
3 changed files with 18 additions and 3 deletions

View File

@ -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.

View File

@ -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 );

View File

@ -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.' );
}