From a9ee47c80625e1f6166c979805bcd4cdc9d87ece Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 22 Sep 2020 12:30:48 +0000 Subject: [PATCH] Tests: Check if image metadata for a particular size was successfully retrieved in some media tests. This outputs a proper message in case of failure, instead of an obscure PHP error further in the test. See #50913. git-svn-id: https://develop.svn.wordpress.org/trunk@49032 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/media.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index 06b8cdb59a..0e8870f6b6 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -1430,7 +1430,7 @@ EOF; } /** - * Helper function to get image size array from size "name" + * Helper function to get image size array from size "name". */ function _get_image_size_array_from_meta( $image_meta, $size_name ) { $array = false; @@ -1443,6 +1443,10 @@ EOF; } } + if ( ! $array ) { + $this->fail( sprintf( "Could not retrieve image metadata for size '%s'.", $size_name ) ); + } + return $array; }