diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index 8dbadd3886..6155946128 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -63,7 +63,27 @@ class Tests_Image_Functions extends WP_UnitTestCase { return $mime_type; } - public function test_is_image_positive() { + /** + * @dataProvider data_is_image_positive + * + * @covers ::file_is_valid_image + * @covers ::wp_getimagesize + * + * @param string $file File name. + */ + public function test_is_image_positive( $file ) { + $this->assertTrue( + file_is_valid_image( DIR_TESTDATA . '/images/' . $file ), + "file_is_valid_image( '$file' ) should return true" + ); + } + + /** + * Data Provider. + * + * @return array + */ + public function data_is_image_positive() { // These are all image files recognized by PHP. $files = array( 'test-image-cmyk.jpg', @@ -77,20 +97,14 @@ class Tests_Image_Functions extends WP_UnitTestCase { 'test-image.psd', 'test-image-zip.tiff', 'test-image.jpg', + 'test-image.ico', 'webp-animated.webp', 'webp-lossless.webp', 'webp-lossy.webp', 'webp-transparent.webp', ); - // IMAGETYPE_ICO is only defined in PHP 5.3+. - if ( defined( 'IMAGETYPE_ICO' ) ) { - $files[] = 'test-image.ico'; - } - - foreach ( $files as $file ) { - $this->assertTrue( file_is_valid_image( DIR_TESTDATA . '/images/' . $file ), "file_is_valid_image($file) should return true" ); - } + return $this->text_array_to_dataprovider( $files ); } public function test_is_image_negative() {