From 90caf2b35fadb6a7100aa905832810e2f1d76fc4 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 19 Jun 2022 17:26:52 +0000 Subject: [PATCH] Tests: Consistently check that an image was loaded in image saving tests. Don't unnecessarily load the image twice in `test_inferred_mime_types_when_saving_an_image()`. Follow-up to [1061/tests], [1151/tests], [1157/tests], [29834]. See #55652. git-svn-id: https://develop.svn.wordpress.org/trunk@53532 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/image/functions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index e3bdf7ae96..c88570c676 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -257,6 +257,8 @@ class Tests_Image_Functions extends WP_UnitTestCase { $img = new $class_name( DIR_TESTDATA . '/images/canola.jpg' ); $loaded = $img->load(); + $this->assertNotWPError( $loaded, 'Image failed to load - WP_Error returned' ); + if ( ! $img->supports_mime_type( $mime_type ) ) { $this->markTestSkipped( sprintf( @@ -332,6 +334,8 @@ class Tests_Image_Functions extends WP_UnitTestCase { $img = new $class_name( DIR_TESTDATA . '/images/canola.jpg' ); $loaded = $img->load(); + $this->assertNotWPError( $loaded, 'Image failed to load - WP_Error returned' ); + // Save the file. $mime_type = 'image/gif'; $file = wp_tempnam( 'tmp.jpg' ); @@ -375,8 +379,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { $img = new $class_name( DIR_TESTDATA . '/images/canola.jpg' ); $loaded = $img->load(); - $img = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); - $this->assertNotWPError( $img ); + $this->assertNotWPError( $loaded, 'Image failed to load - WP_Error returned' ); if ( ! $img->supports_mime_type( $mime_type ) ) { $this->markTestSkipped(