diff --git a/tests/phpunit/tests/http/functions.php b/tests/phpunit/tests/http/functions.php index 9a2b1ba172..79e0727460 100644 --- a/tests/phpunit/tests/http/functions.php +++ b/tests/phpunit/tests/http/functions.php @@ -3,10 +3,15 @@ /** * @group http * @group external-http - * - * @requires extension openssl */ class Tests_HTTP_Functions extends WP_UnitTestCase { + public function setUp() { + if ( ! extension_loaded( 'openssl' ) ) { + $this->markTestSkipped( 'Tests_HTTP_Functions requires openssl.' ); + } + + parent::setUp(); + } function test_head_request() { // this url give a direct 200 response diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index 0f2ae01e1c..9cc3f09d2a 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -108,10 +108,12 @@ class Tests_Image_Functions extends WP_UnitTestCase { /** * Test save image file and mime_types * @ticket 6821 - * - * @requires extension fileinfo */ public function test_wp_save_image_file() { + if ( ! extension_loaded( 'fileinfo' ) ) { + $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' ); + } + include_once( ABSPATH . 'wp-admin/includes/image-edit.php' ); // Mime types @@ -158,10 +160,12 @@ class Tests_Image_Functions extends WP_UnitTestCase { /** * Test that a passed mime type overrides the extension in the filename * @ticket 6821 - * - * @requires extension fileinfo */ public function test_mime_overrides_filename() { + if ( ! extension_loaded( 'fileinfo' ) ) { + $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' ); + } + // Test each image editor engine $classes = array('WP_Image_Editor_GD', 'WP_Image_Editor_Imagick'); foreach ( $classes as $class ) { @@ -194,10 +198,12 @@ class Tests_Image_Functions extends WP_UnitTestCase { /** * Test that mime types are correctly inferred from file extensions * @ticket 6821 - * - * @requires extension fileinfo */ public function test_inferred_mime_types() { + if ( ! extension_loaded( 'fileinfo' ) ) { + $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' ); + } + // Mime types $mime_types = array( 'jpg' => 'image/jpeg', @@ -290,11 +296,14 @@ class Tests_Image_Functions extends WP_UnitTestCase { unlink( $file ); } - /** - * @requires extension openssl - * @requires function imagejpeg - */ public function test_wp_crop_image_url() { + if ( !function_exists( 'imagejpeg' ) ) + $this->markTestSkipped( 'jpeg support unavailable' ); + + if ( ! extension_loaded( 'openssl' ) ) { + $this->markTestSkipped( 'Tests_Image_Functions::test_wp_crop_image_url() requires openssl.' ); + } + $file = wp_crop_image( 'https://asdftestblog1.files.wordpress.com/2008/04/canola.jpg', 0, 0, 100, 100, 100, 100, false, DIR_TESTDATA . '/images/' . rand_str() . '.jpg' ); @@ -314,10 +323,11 @@ class Tests_Image_Functions extends WP_UnitTestCase { $this->assertInstanceOf( 'WP_Error', $file ); } - /** - * @requires extension openssl - */ public function test_wp_crop_image_url_not_exist() { + if ( ! extension_loaded( 'openssl' ) ) { + $this->markTestSkipped( 'Tests_Image_Functions::test_wp_crop_image_url_not_exist() requires openssl.' ); + } + $file = wp_crop_image( 'https://asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg', 0, 0, 100, 100, 100, 100 ); $this->assertInstanceOf( 'WP_Error', $file ); diff --git a/tests/phpunit/tests/image/meta.php b/tests/phpunit/tests/image/meta.php index a29c4a3e35..30613d48a8 100644 --- a/tests/phpunit/tests/image/meta.php +++ b/tests/phpunit/tests/image/meta.php @@ -4,11 +4,17 @@ * @group image * @group media * @group upload - * - * @requires extension gd - * @requires extension exif */ class Tests_Image_Meta extends WP_UnitTestCase { + function setUp() { + if ( ! extension_loaded( 'gd' ) ) + $this->markTestSkipped( 'The gd PHP extension is not loaded.' ); + if ( ! extension_loaded( 'exif' ) ) + $this->markTestSkipped( 'The exif PHP extension is not loaded.' ); + if ( ! is_callable( 'wp_read_image_metadata' ) ) + $this->markTestSkipped( 'wp_read_image_metadata() is not callable.' ); + parent::setUp(); + } function test_exif_d70() { // exif from a Nikon D70