diff --git a/tests/phpunit/tests/functions/deprecated.php b/tests/phpunit/tests/functions/deprecated.php index a9046742ad..b9b86455c1 100644 --- a/tests/phpunit/tests/functions/deprecated.php +++ b/tests/phpunit/tests/functions/deprecated.php @@ -143,14 +143,11 @@ class Tests_Functions_Deprecated extends WP_UnitTestCase { * * @ticket 6821 * @expectedDeprecated wp_save_image_file + * @requires function imagejpeg * * @covers ::wp_save_image_file */ public function test_wp_save_image_file_deprecated_with_gd_resource() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - // Call wp_save_image_file(). require_once ABSPATH . 'wp-admin/includes/image-edit.php'; $file = wp_tempnam(); @@ -168,14 +165,11 @@ class Tests_Functions_Deprecated extends WP_UnitTestCase { * Tests that wp_save_image_file() doesn't have a deprecated argument when passed a WP_Image_Editor. * * @ticket 6821 + * @requires function imagejpeg * * @covers ::wp_save_image_file */ public function test_wp_save_image_file_not_deprecated_with_wp_image_editor() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - // Call wp_save_image_file(). require_once ABSPATH . 'wp-admin/includes/image-edit.php'; $file = wp_tempnam(); diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index eed4aa9f2e..3493c81913 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -348,11 +348,10 @@ class Tests_Image_Functions extends WP_UnitTestCase { } } + /** + * @requires function imagejpeg + */ public function test_wp_crop_image_file() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - $file = wp_crop_image( DIR_TESTDATA . '/images/canola.jpg', 0, @@ -372,11 +371,10 @@ class Tests_Image_Functions extends WP_UnitTestCase { unlink( $file ); } + /** + * @requires function imagejpeg + */ public function test_wp_crop_image_url() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - if ( ! extension_loaded( 'openssl' ) ) { $this->markTestSkipped( 'Tests_Image_Functions::test_wp_crop_image_url() requires openssl.' ); } diff --git a/tests/phpunit/tests/image/intermediateSize.php b/tests/phpunit/tests/image/intermediateSize.php index 6b7427c8fa..b92c833a9d 100644 --- a/tests/phpunit/tests/image/intermediateSize.php +++ b/tests/phpunit/tests/image/intermediateSize.php @@ -28,31 +28,28 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { $this->assertFalse( $image ); } + /** + * @requires function imagejpeg + */ function test_make_intermediate_size_width() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 0, false ); $this->assertInternalType( 'array', $image ); } + /** + * @requires function imagejpeg + */ function test_make_intermediate_size_height() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 0, 75, false ); $this->assertInternalType( 'array', $image ); } + /** + * @requires function imagejpeg + */ function test_make_intermediate_size_successful() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 75, true ); $this->assertInternalType( 'array', $image ); @@ -67,12 +64,9 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { /** * @ticket 17626 + * @requires function imagejpeg */ function test_get_intermediate_sizes_by_name() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - add_image_size( 'test-size', 330, 220, true ); $file = DIR_TESTDATA . '/images/waffles.jpg'; @@ -91,12 +85,9 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { /** * @ticket 17626 + * @requires function imagejpeg */ function test_get_intermediate_sizes_by_array_exact() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - // Only one dimention match shouldn't return false positive (see: #17626). add_image_size( 'test-size', 330, 220, true ); add_image_size( 'false-height', 330, 400, true ); @@ -116,12 +107,9 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { /** * @ticket 17626 + * @requires function imagejpeg */ function test_get_intermediate_sizes_by_array_nearest() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - // If an exact size is not found, it should be returned. // If not, find nearest size that is larger (see: #17626). add_image_size( 'test-size', 450, 300, true ); @@ -163,12 +151,9 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { /** * @ticket 17626 + * @requires function imagejpeg */ function test_get_intermediate_sizes_by_array_zero_height() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - // Generate random width. $random_w = rand( 300, 400 ); @@ -195,12 +180,9 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { /** * @ticket 17626 * @ticket 34087 + * @requires function imagejpeg */ function test_get_intermediate_sizes_by_array_zero_width() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - // 202 is the smallest height that will trigger a miss for 'false-height'. $height = 202; @@ -227,12 +209,9 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { /** * @ticket 17626 * @ticket 34087 + * @requires function imagejpeg */ public function test_get_intermediate_sizes_should_match_size_with_off_by_one_aspect_ratio() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - // Original is 600x400. 300x201 is close enough to match. $width = 300; $height = 201; @@ -254,12 +233,9 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { /** * @ticket 34384 + * @requires function imagejpeg */ public function test_get_intermediate_size_with_small_size_array() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - // Add a hard cropped size that matches the aspect ratio we're going to test. add_image_size( 'test-size', 200, 100, true ); @@ -275,12 +251,9 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { /** * @ticket 34384 + * @requires function imagejpeg */ public function test_get_intermediate_size_with_small_size_array_fallback() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - $file = DIR_TESTDATA . '/images/waffles.jpg'; $id = $this->_make_attachment( $file, 0 ); diff --git a/tests/phpunit/tests/post/attachments.php b/tests/phpunit/tests/post/attachments.php index 8f75c41b5a..0a03d77ed6 100644 --- a/tests/phpunit/tests/post/attachments.php +++ b/tests/phpunit/tests/post/attachments.php @@ -54,11 +54,10 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $this->assertSame( 50, $downsize[2] ); } + /** + * @requires function imagejpeg + */ function test_insert_image_thumb_only() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - update_option( 'medium_size_w', 0 ); update_option( 'medium_size_h', 0 ); @@ -106,11 +105,10 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $this->assertSame( 300, $downsize[2] ); } + /** + * @requires function imagejpeg + */ function test_insert_image_medium_sizes() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - update_option( 'medium_size_w', 400 ); update_option( 'medium_size_h', 0 ); @@ -164,12 +162,10 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $this->assertSame( 1024, $downsize[2] ); } - + /** + * @requires function imagejpeg + */ function test_insert_image_delete() { - if ( ! function_exists( 'imagejpeg' ) ) { - $this->fail( 'jpeg support unavailable' ); - } - update_option( 'medium_size_w', 400 ); update_option( 'medium_size_h', 0 );