Skip to content

Commit b45f2fe

Browse files
committed
Build/Test Tools: Revert [38759]. PHPUnit's @requires syntax was introduced in PHPUnit 3.7, but the tests for PHP 5.2 use PHPUnit 3.6 because it's the latest version that supports PHP 5.2.
Fixes #38256 git-svn-id: https://develop.svn.wordpress.org/trunk@38761 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 471103d commit b45f2fe

3 files changed

Lines changed: 39 additions & 18 deletions

File tree

tests/phpunit/tests/http/functions.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
/**
44
* @group http
55
* @group external-http
6-
*
7-
* @requires extension openssl
86
*/
97
class Tests_HTTP_Functions extends WP_UnitTestCase {
8+
public function setUp() {
9+
if ( ! extension_loaded( 'openssl' ) ) {
10+
$this->markTestSkipped( 'Tests_HTTP_Functions requires openssl.' );
11+
}
12+
13+
parent::setUp();
14+
}
1015

1116
function test_head_request() {
1217
// this url give a direct 200 response

tests/phpunit/tests/image/functions.php

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ function test_is_displayable_image_negative() {
108108
/**
109109
* Test save image file and mime_types
110110
* @ticket 6821
111-
*
112-
* @requires extension fileinfo
113111
*/
114112
public function test_wp_save_image_file() {
113+
if ( ! extension_loaded( 'fileinfo' ) ) {
114+
$this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
115+
}
116+
115117
include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
116118

117119
// Mime types
@@ -158,10 +160,12 @@ public function test_wp_save_image_file() {
158160
/**
159161
* Test that a passed mime type overrides the extension in the filename
160162
* @ticket 6821
161-
*
162-
* @requires extension fileinfo
163163
*/
164164
public function test_mime_overrides_filename() {
165+
if ( ! extension_loaded( 'fileinfo' ) ) {
166+
$this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
167+
}
168+
165169
// Test each image editor engine
166170
$classes = array('WP_Image_Editor_GD', 'WP_Image_Editor_Imagick');
167171
foreach ( $classes as $class ) {
@@ -194,10 +198,12 @@ public function test_mime_overrides_filename() {
194198
/**
195199
* Test that mime types are correctly inferred from file extensions
196200
* @ticket 6821
197-
*
198-
* @requires extension fileinfo
199201
*/
200202
public function test_inferred_mime_types() {
203+
if ( ! extension_loaded( 'fileinfo' ) ) {
204+
$this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
205+
}
206+
201207
// Mime types
202208
$mime_types = array(
203209
'jpg' => 'image/jpeg',
@@ -290,11 +296,14 @@ public function test_wp_crop_image_file() {
290296
unlink( $file );
291297
}
292298

293-
/**
294-
* @requires extension openssl
295-
* @requires function imagejpeg
296-
*/
297299
public function test_wp_crop_image_url() {
300+
if ( !function_exists( 'imagejpeg' ) )
301+
$this->markTestSkipped( 'jpeg support unavailable' );
302+
303+
if ( ! extension_loaded( 'openssl' ) ) {
304+
$this->markTestSkipped( 'Tests_Image_Functions::test_wp_crop_image_url() requires openssl.' );
305+
}
306+
298307
$file = wp_crop_image( 'https://asdftestblog1.files.wordpress.com/2008/04/canola.jpg',
299308
0, 0, 100, 100, 100, 100, false,
300309
DIR_TESTDATA . '/images/' . rand_str() . '.jpg' );
@@ -314,10 +323,11 @@ public function test_wp_crop_image_file_not_exist() {
314323
$this->assertInstanceOf( 'WP_Error', $file );
315324
}
316325

317-
/**
318-
* @requires extension openssl
319-
*/
320326
public function test_wp_crop_image_url_not_exist() {
327+
if ( ! extension_loaded( 'openssl' ) ) {
328+
$this->markTestSkipped( 'Tests_Image_Functions::test_wp_crop_image_url_not_exist() requires openssl.' );
329+
}
330+
321331
$file = wp_crop_image( 'https://asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg',
322332
0, 0, 100, 100, 100, 100 );
323333
$this->assertInstanceOf( 'WP_Error', $file );

tests/phpunit/tests/image/meta.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44
* @group image
55
* @group media
66
* @group upload
7-
*
8-
* @requires extension gd
9-
* @requires extension exif
107
*/
118
class Tests_Image_Meta extends WP_UnitTestCase {
9+
function setUp() {
10+
if ( ! extension_loaded( 'gd' ) )
11+
$this->markTestSkipped( 'The gd PHP extension is not loaded.' );
12+
if ( ! extension_loaded( 'exif' ) )
13+
$this->markTestSkipped( 'The exif PHP extension is not loaded.' );
14+
if ( ! is_callable( 'wp_read_image_metadata' ) )
15+
$this->markTestSkipped( 'wp_read_image_metadata() is not callable.' );
16+
parent::setUp();
17+
}
1218

1319
function test_exif_d70() {
1420
// exif from a Nikon D70

0 commit comments

Comments
 (0)