diff --git a/tests/phpunit/tests/ajax/MediaEdit.php b/tests/phpunit/tests/ajax/MediaEdit.php index 0060083820..aa6e6786a6 100644 --- a/tests/phpunit/tests/ajax/MediaEdit.php +++ b/tests/phpunit/tests/ajax/MediaEdit.php @@ -11,6 +11,8 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php'; * @subpackage UnitTests * @since 3.5.0 * @group ajax + * + * @requires function imagejpeg */ class Tests_Ajax_MediaEdit extends WP_Ajax_UnitTestCase { @@ -25,7 +27,6 @@ class Tests_Ajax_MediaEdit extends WP_Ajax_UnitTestCase { /** * @ticket 22985 - * @requires function imagejpeg */ public function testCropImageThumbnail() { require_once ABSPATH . 'wp-admin/includes/image-edit.php'; @@ -55,7 +56,6 @@ class Tests_Ajax_MediaEdit extends WP_Ajax_UnitTestCase { /** * @ticket 32171 - * @requires function imagejpeg */ public function testImageEditOverwriteConstant() { define( 'IMAGE_EDIT_OVERWRITE', true ); diff --git a/tests/phpunit/tests/cache.php b/tests/phpunit/tests/cache.php index 79654fcaa9..0874bed8e1 100644 --- a/tests/phpunit/tests/cache.php +++ b/tests/phpunit/tests/cache.php @@ -251,7 +251,7 @@ class Tests_Cache extends WP_UnitTestCase { function test_switch_to_blog() { if ( ! method_exists( $this->cache, 'switch_to_blog' ) ) { - return; + $this->markTestSkipped( 'This test requires a switch_to_blog() method on the cache object.' ); } $key = __FUNCTION__; diff --git a/tests/phpunit/tests/compat.php b/tests/phpunit/tests/compat.php index cc6cf805e5..766b8fe545 100644 --- a/tests/phpunit/tests/compat.php +++ b/tests/phpunit/tests/compat.php @@ -242,12 +242,10 @@ EOT; * Test is_countable() polyfill for ResourceBundle. * * @ticket 43583 + * + * @requires extension intl */ function test_is_countable_ResourceBundle() { - if ( ! class_exists( 'ResourceBundle' ) ) { - $this->markTestSkipped( 'The intl extension is not loaded. ResourceBundle not tested for is_countable().' ); - } - $this->assertTrue( is_countable( new ResourceBundle( 'en', null ) ) ); } @@ -255,12 +253,10 @@ EOT; * Test is_countable() polyfill for SimpleXMLElement. * * @ticket 43583 + * + * @requires extension simplexml */ function test_is_countable_SimpleXMLElement() { - if ( ! class_exists( 'SimpleXMLElement' ) ) { - $this->markTestSkipped( 'The xml extension is not loaded. SimpleXMLElement not tested for is_countable().' ); - } - $this->assertTrue( is_countable( new SimpleXMLElement( '12' ) ) ); } diff --git a/tests/phpunit/tests/customize/manager.php b/tests/phpunit/tests/customize/manager.php index a2a0365f24..8ae0c5d138 100644 --- a/tests/phpunit/tests/customize/manager.php +++ b/tests/phpunit/tests/customize/manager.php @@ -541,6 +541,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * * @covers WP_Customize_Manager::import_theme_starter_content * @covers WP_Customize_Manager::_save_starter_content_changeset + * @requires function imagejpeg */ function test_import_theme_starter_content() { wp_set_current_user( self::$admin_user_id ); diff --git a/tests/phpunit/tests/db/charset.php b/tests/phpunit/tests/db/charset.php index 97a2d8136f..ecb3b10edb 100644 --- a/tests/phpunit/tests/db/charset.php +++ b/tests/phpunit/tests/db/charset.php @@ -762,7 +762,6 @@ class Tests_DB_Charset extends WP_UnitTestCase { if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) { $this->markTestSkipped( "This version of MySQL doesn't support utf8mb4." ); - return; } self::$_wpdb->query( $create ); @@ -804,7 +803,6 @@ class Tests_DB_Charset extends WP_UnitTestCase { if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) { $this->markTestSkipped( "This version of MySQL doesn't support utf8mb4." ); - return; } self::$_wpdb->query( $create ); @@ -828,7 +826,6 @@ class Tests_DB_Charset extends WP_UnitTestCase { if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) { $this->markTestSkipped( "This version of MySQL doesn't support utf8mb4." ); - return; } self::$_wpdb->is_mysql = false; @@ -856,7 +853,6 @@ class Tests_DB_Charset extends WP_UnitTestCase { if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) { $this->markTestSkipped( "This version of MySQL doesn't support utf8mb4." ); - return; } unset( self::$_wpdb->is_mysql ); @@ -917,7 +913,6 @@ class Tests_DB_Charset extends WP_UnitTestCase { if ( ! self::$_wpdb->has_cap( 'utf8mb4' ) && preg_match( '/utf8mb[34]/i', $create ) ) { $this->markTestSkipped( "This version of MySQL doesn't support utf8mb4." ); - return; } self::$_wpdb->query( $create ); diff --git a/tests/phpunit/tests/functions/anonymization.php b/tests/phpunit/tests/functions/anonymization.php index d8a941da34..9ca33b441e 100644 --- a/tests/phpunit/tests/functions/anonymization.php +++ b/tests/phpunit/tests/functions/anonymization.php @@ -25,8 +25,6 @@ class Tests_Functions_Anonymization extends WP_UnitTestCase { * * @ticket 41083 * @ticket 43545 - * @requires function inet_ntop - * @requires function inet_pton * * @param string $raw_ip Raw IP address. * @param string $expected_result Expected result. @@ -90,26 +88,6 @@ class Tests_Functions_Anonymization extends WP_UnitTestCase { '1000:0000:0000:0000:0000:0000:0000:0001or=\"', '::', ), - // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings. - array( - 'or=\"[1000:0000:0000:0000:0000:0000:0000:0001]:400', - '1000::', - ), - // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings. - array( - 'or=\"[1000:0000:0000:0000:0000:0000:0000:0001]', - '1000::', - ), - // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings. - array( - 'or=\"[1000:0000:0000:0000:0000:0000:0000:0001]400', - '1000::', - ), - // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings. - array( - '[1000:0000:0000:0000:0000:0000:0000:0001]:235\"or=', - '1000::', - ), // IPv4, no port. array( '10.20.30.45', @@ -125,36 +103,16 @@ class Tests_Functions_Anonymization extends WP_UnitTestCase { '10.20.30.45/24', '10.20.30.0', ), - // IPv6, no port. - array( - '2a03:2880:2110:df07:face:b00c::1', - '2a03:2880:2110:df07::', - ), - // IPv6, port. - array( - '[2a03:2880:2110:df07:face:b00c::1]:20000', - '2a03:2880:2110:df07::', - ), // IPv6, no port, reducible representation. array( '0000:0000:0000:0000:0000:0000:0000:0001', '::', ), - // IPv6, no port, partially reducible representation. - array( - '1000:0000:0000:0000:0000:0000:0000:0001', - '1000::', - ), // IPv6, port, reducible representation. array( '[0000:0000:0000:0000:0000:0000:0000:0001]:1234', '::', ), - // IPv6, port, partially reducible representation. - array( - '[1000:0000:0000:0000:0000:0000:0000:0001]:5678', - '1000::', - ), // IPv6, no port, reduced representation. array( '::', @@ -195,6 +153,80 @@ class Tests_Functions_Anonymization extends WP_UnitTestCase { '[::127.0.0.1]:30000', '::ffff:127.0.0.0', ), + ); + } + + /** + * Test that wp_privacy_anonymize_ip() properly anonymizes all possible IP address formats. + * + * @dataProvider data_wp_privacy_anonymize_ip_with_inet_dependency + * + * @ticket 41083 + * @ticket 43545 + * @requires function inet_ntop + * @requires function inet_pton + * + * @param string $raw_ip Raw IP address. + * @param string $expected_result Expected result. + */ + public function test_wp_privacy_anonymize_ip_with_inet_dependency( $raw_ip, $expected_result ) { + $this->test_wp_privacy_anonymize_ip( $raw_ip, $expected_result ); + } + + /** + * Provide test cases for `test_wp_privacy_anonymize_ip()`. + * + * @since 4.9.6 Moved from `Test_WP_Community_Events::data_get_unsafe_client_ip_anonymization()`. + * + * @return array { + * @type array { + * @string string $raw_ip Raw IP address. + * @string string $expected_result Expected result. + * } + * } + */ + public function data_wp_privacy_anonymize_ip_with_inet_dependency() { + return array( + // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings. + array( + 'or=\"[1000:0000:0000:0000:0000:0000:0000:0001]:400', + '1000::', + ), + // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings. + array( + 'or=\"[1000:0000:0000:0000:0000:0000:0000:0001]', + '1000::', + ), + // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings. + array( + 'or=\"[1000:0000:0000:0000:0000:0000:0000:0001]400', + '1000::', + ), + // Malformed string with valid IP substring. Sometimes proxies add things like this, or other arbitrary strings. + array( + '[1000:0000:0000:0000:0000:0000:0000:0001]:235\"or=', + '1000::', + ), + // IPv6, no port. + array( + '2a03:2880:2110:df07:face:b00c::1', + '2a03:2880:2110:df07::', + ), + // IPv6, port. + array( + '[2a03:2880:2110:df07:face:b00c::1]:20000', + '2a03:2880:2110:df07::', + ), + // IPv6, no port, partially reducible representation. + array( + '1000:0000:0000:0000:0000:0000:0000:0001', + '1000::', + ), + // IPv6, port, partially reducible representation. + array( + '[1000:0000:0000:0000:0000:0000:0000:0001]:5678', + '1000::', + ), // IPv6 with reachability scope. array( 'fe80::b059:65f4:e877:c40%16', diff --git a/tests/phpunit/tests/general/template.php b/tests/phpunit/tests/general/template.php index 49545adb90..03c543dfa5 100644 --- a/tests/phpunit/tests/general/template.php +++ b/tests/phpunit/tests/general/template.php @@ -35,6 +35,7 @@ class Tests_General_Template extends WP_UnitTestCase { /** * @group site_icon * @covers ::get_site_icon_url + * @requires function imagejpeg */ function test_get_site_icon_url() { $this->assertEmpty( get_site_icon_url() ); @@ -49,6 +50,7 @@ class Tests_General_Template extends WP_UnitTestCase { /** * @group site_icon * @covers ::site_icon_url + * @requires function imagejpeg */ function test_site_icon_url() { $this->expectOutputString( '' ); @@ -62,6 +64,7 @@ class Tests_General_Template extends WP_UnitTestCase { /** * @group site_icon * @covers ::has_site_icon + * @requires function imagejpeg */ function test_has_site_icon() { $this->assertFalse( has_site_icon() ); @@ -103,6 +106,7 @@ class Tests_General_Template extends WP_UnitTestCase { /** * @group site_icon * @covers ::wp_site_icon + * @requires function imagejpeg */ function test_wp_site_icon() { $this->expectOutputString( '' ); @@ -125,6 +129,7 @@ class Tests_General_Template extends WP_UnitTestCase { /** * @group site_icon * @covers ::wp_site_icon + * @requires function imagejpeg */ function test_wp_site_icon_with_filter() { $this->expectOutputString( '' ); diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php index c192065dbf..14aa731cec 100644 --- a/tests/phpunit/tests/http/base.php +++ b/tests/phpunit/tests/http/base.php @@ -20,11 +20,6 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { function setUp() { parent::setUp(); - if ( is_callable( array( 'WP_Http', '_getTransport' ) ) ) { - $this->markTestSkipped( 'The WP_Http tests require a class-http.php file of r17550 or later.' ); - return; - } - $class = 'WP_Http_' . ucfirst( $this->transport ); if ( ! call_user_func( array( $class, 'test' ) ) ) { $this->markTestSkipped( sprintf( 'The transport %s is not supported on this system.', $this->transport ) ); diff --git a/tests/phpunit/tests/http/functions.php b/tests/phpunit/tests/http/functions.php index 05500cc407..c31803dead 100644 --- a/tests/phpunit/tests/http/functions.php +++ b/tests/phpunit/tests/http/functions.php @@ -3,7 +3,6 @@ /** * @group http * @group external-http - * @requires extension openssl */ class Tests_HTTP_Functions extends WP_UnitTestCase { diff --git a/tests/phpunit/tests/image/editorGd.php b/tests/phpunit/tests/image/editorGd.php index d2523f4c6f..ed26316503 100644 --- a/tests/phpunit/tests/image/editorGd.php +++ b/tests/phpunit/tests/image/editorGd.php @@ -53,6 +53,8 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { /** * Test resizing an image, not using crop + * + * @requires function imagejpeg */ public function test_resize() { $file = DIR_TESTDATA . '/images/waffles.jpg'; @@ -73,6 +75,8 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { /** * Test multi_resize with single image resize and no crop + * + * @requires function imagejpeg */ public function test_single_multi_resize() { $file = DIR_TESTDATA . '/images/waffles.jpg'; @@ -183,6 +187,7 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { * Test multi_resize with multiple sizes * * @ticket 26823 + * @requires function imagejpeg */ public function test_multi_resize() { $file = DIR_TESTDATA . '/images/waffles.jpg'; diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index 3f79070b09..204a79a648 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -172,18 +172,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { * @requires extension fileinfo */ public function test_wp_save_image_file() { - $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); - - foreach ( $classes as $key => $class ) { - if ( ! call_user_func( array( $class, 'test' ) ) ) { - // If the image editor isn't available, skip it. - unset( $classes[ $key ] ); - } - } - - if ( ! $classes ) { - $this->markTestSkipped( sprintf( 'The image editor engine %s is not supported on this system.', 'WP_Image_Editor_GD' ) ); - } + $classes = $this->get_image_editor_engine_classes(); require_once ABSPATH . 'wp-admin/includes/image-edit.php'; @@ -233,18 +222,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { * @requires extension fileinfo */ public function test_mime_overrides_filename() { - $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); - - foreach ( $classes as $key => $class ) { - if ( ! call_user_func( array( $class, 'test' ) ) ) { - // If the image editor isn't available, skip it. - unset( $classes[ $key ] ); - } - } - - if ( ! $classes ) { - $this->markTestSkipped( sprintf( 'The image editor engine %s is not supported on this system.', 'WP_Image_Editor_GD' ) ); - } + $classes = $this->get_image_editor_engine_classes(); // Test each image editor engine. foreach ( $classes as $class ) { @@ -275,18 +253,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { * @requires extension fileinfo */ public function test_inferred_mime_types() { - $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); - - foreach ( $classes as $key => $class ) { - if ( ! call_user_func( array( $class, 'test' ) ) ) { - // If the image editor isn't available, skip it. - unset( $classes[ $key ] ); - } - } - - if ( ! $classes ) { - $this->markTestSkipped( sprintf( 'The image editor engine %s is not supported on this system.', 'WP_Image_Editor_GD' ) ); - } + $classes = $this->get_image_editor_engine_classes(); // Mime types. $mime_types = array( @@ -342,18 +309,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { $editor2 = wp_get_image_editor( DIR_TESTDATA ); $this->assertInstanceOf( 'WP_Error', $editor2 ); - $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); - - foreach ( $classes as $key => $class ) { - if ( ! call_user_func( array( $class, 'test' ) ) ) { - // If the image editor isn't available, skip it. - unset( $classes[ $key ] ); - } - } - - if ( ! $classes ) { - $this->markTestSkipped( sprintf( 'The image editor engine %s is not supported on this system.', 'WP_Image_Editor_GD' ) ); - } + $classes = $this->get_image_editor_engine_classes(); // Then, test with editors. foreach ( $classes as $class ) { @@ -365,6 +321,28 @@ class Tests_Image_Functions extends WP_UnitTestCase { } } + /** + * Get the available image editor engine class(es). + * + * @return string[] Available image editor classes; empty array when none are avaialble. + */ + private function get_image_editor_engine_classes() { + $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); + + foreach ( $classes as $key => $class ) { + if ( ! call_user_func( array( $class, 'test' ) ) ) { + // If the image editor isn't available, skip it. + unset( $classes[ $key ] ); + } + } + + if ( empty( $classes ) ) { + $this->markTestSkipped( 'Image editor engines WP_Image_Editor_GD and WP_Image_Editor_Imagick are not supported on this system.' ); + } + + return $classes; + } + /** * @requires function imagejpeg */ diff --git a/tests/phpunit/tests/image/intermediateSize.php b/tests/phpunit/tests/image/intermediateSize.php index 9b0e651c82..122971a069 100644 --- a/tests/phpunit/tests/image/intermediateSize.php +++ b/tests/phpunit/tests/image/intermediateSize.php @@ -156,6 +156,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { /** * @ticket 17626 + * @requires function imagejpeg */ function test_get_intermediate_sizes_by_array_nearest_false() { // If an exact size is not found, it should be returned. diff --git a/tests/phpunit/tests/image/resizeGd.php b/tests/phpunit/tests/image/resizeGd.php index 55fd8b3bac..171bc3f30a 100644 --- a/tests/phpunit/tests/image/resizeGd.php +++ b/tests/phpunit/tests/image/resizeGd.php @@ -5,6 +5,8 @@ * @group media * @group upload * @group resize + * + * @requires function imagejpeg */ require_once __DIR__ . '/resize.php'; diff --git a/tests/phpunit/tests/l10n/getLocale.php b/tests/phpunit/tests/l10n/getLocale.php index 391ad08ed7..5a212019b9 100644 --- a/tests/phpunit/tests/l10n/getLocale.php +++ b/tests/phpunit/tests/l10n/getLocale.php @@ -39,7 +39,7 @@ class Tests_L10n_GetLocale extends WP_UnitTestCase { */ public function test_network_option_should_be_fallback_on_multisite() { if ( ! is_multisite() ) { - $this->markTestSkipped( __METHOD__ . ' requires Multisite.' ); + $this->markTestSkipped( 'This test requires Multisite.' ); } global $locale; @@ -59,7 +59,7 @@ class Tests_L10n_GetLocale extends WP_UnitTestCase { */ public function test_option_should_be_respected_on_nonmultisite() { if ( is_multisite() ) { - $this->markTestSkipped( __METHOD__ . ' does not apply to Multisite.' ); + $this->markTestSkipped( 'This test does not apply to Multisite.' ); } global $locale; diff --git a/tests/phpunit/tests/l10n/getUserLocale.php b/tests/phpunit/tests/l10n/getUserLocale.php index f1d6f3828a..35f46b2454 100644 --- a/tests/phpunit/tests/l10n/getUserLocale.php +++ b/tests/phpunit/tests/l10n/getUserLocale.php @@ -72,7 +72,7 @@ class Tests_L10n_GetUserLocale extends WP_UnitTestCase { */ public function test_user_locale_is_same_across_network() { if ( ! is_multisite() ) { - $this->markTestSkipped( __METHOD__ . ' requires Multisite.' ); + $this->markTestSkipped( 'This test requires Multisite.' ); } $user_locale = get_user_locale(); diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index 816ba75b51..5c9512cd0a 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -1722,6 +1722,7 @@ EOF; /** * @ticket 33641 + * @requires function imagejpeg */ function test_wp_calculate_image_srcset_no_width() { $file = get_attached_file( self::$large_id ); diff --git a/tests/phpunit/tests/pomo/mo.php b/tests/phpunit/tests/pomo/mo.php index 8539e5e431..92d8cd21fb 100644 --- a/tests/phpunit/tests/pomo/mo.php +++ b/tests/phpunit/tests/pomo/mo.php @@ -179,7 +179,7 @@ class Tests_POMO_MO extends WP_UnitTestCase { function test_overloaded_mb_functions() { if ( ( ini_get( 'mbstring.func_overload' ) & 2 ) === 0 ) { - $this->markTestSkipped( __METHOD__ . ' only runs when mbstring.func_overload is enabled.' ); + $this->markTestSkipped( 'This test requires mbstring.func_overload to be enabled.' ); } $mo = new MO(); diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php index fab7c48a71..a2f7087528 100644 --- a/tests/phpunit/tests/rest-api/rest-attachments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-attachments-controller.php @@ -743,6 +743,9 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $this->assertErrorResponse( 'rest_forbidden', $response, 401 ); } + /** + * @requires function imagejpeg + */ public function test_create_item() { wp_set_current_user( self::$author_id ); @@ -792,6 +795,9 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $this->assertSame( 'codeispoetry', $data['title']['raw'] ); } + /** + * @requires function imagejpeg + */ public function test_create_item_with_files() { wp_set_current_user( self::$author_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/media' ); @@ -810,6 +816,9 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $this->assertSame( 201, $response->get_status() ); } + /** + * @requires function imagejpeg + */ public function test_create_item_with_upload_files_role() { wp_set_current_user( self::$uploader_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/media' ); @@ -924,6 +933,9 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); } + /** + * @requires function imagejpeg + */ public function test_create_item_alt_text() { wp_set_current_user( self::$author_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/media' ); @@ -937,6 +949,9 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $this->assertSame( 'test alt text', $attachment['alt_text'] ); } + /** + * @requires function imagejpeg + */ public function test_create_item_unsafe_alt_text() { wp_set_current_user( self::$author_id ); $request = new WP_REST_Request( 'POST', '/wp/v2/media' ); @@ -951,6 +966,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control /** * @ticket 40861 + * @requires function imagejpeg */ public function test_create_item_ensure_relative_path() { wp_set_current_user( self::$author_id ); @@ -1274,6 +1290,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control /** * @dataProvider attachment_roundtrip_provider + * @requires function imagejpeg */ public function test_post_roundtrip_as_author( $raw, $expected ) { wp_set_current_user( self::$author_id ); @@ -1281,6 +1298,9 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $this->verify_attachment_roundtrip( $raw, $expected ); } + /** + * @requires function imagejpeg + */ public function test_attachment_roundtrip_as_editor_unfiltered_html() { wp_set_current_user( self::$editor_id ); if ( is_multisite() ) { @@ -1332,6 +1352,9 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control } } + /** + * @requires function imagejpeg + */ public function test_attachment_roundtrip_as_superadmin_unfiltered_html() { wp_set_current_user( self::$superadmin_id ); $this->assertTrue( current_user_can( 'unfiltered_html' ) ); @@ -1808,6 +1831,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control * once when attachments are created. * * @ticket 45269 + * @requires function imagejpeg */ public function test_rest_insert_attachment_hooks_fire_once_on_create() { self::$rest_insert_attachment_count = 0; @@ -1865,6 +1889,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control /** * @ticket 44567 + * @requires function imagejpeg */ public function test_create_item_with_meta_values() { register_post_meta( @@ -1902,6 +1927,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control /** * @ticket 44405 + * @requires function imagejpeg */ public function test_edit_image_returns_error_if_logged_out() { $attachment = self::factory()->attachment->create_upload_object( $this->test_file ); @@ -1914,6 +1940,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control /** * @ticket 44405 + * @requires function imagejpeg */ public function test_edit_image_returns_error_if_cannot_upload() { $user = self::factory()->user->create_and_get( array( 'role' => 'editor' ) ); @@ -1930,6 +1957,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control /** * @ticket 44405 + * @requires function imagejpeg */ public function test_edit_image_returns_error_if_cannot_edit() { wp_set_current_user( self::$uploader_id ); @@ -1956,6 +1984,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control /** * @ticket 44405 + * @requires function imagejpeg */ public function test_edit_image_returns_error_if_unsupported_mime_type() { wp_set_current_user( self::$superadmin_id ); @@ -1975,6 +2004,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control /** * @ticket 44405 + * @requires function imagejpeg */ public function test_edit_image_returns_error_if_no_edits() { wp_set_current_user( self::$superadmin_id ); @@ -1988,6 +2018,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control /** * @ticket 44405 + * @requires function imagejpeg */ public function test_edit_image_rotate() { wp_set_current_user( self::$superadmin_id ); @@ -2012,6 +2043,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control /** * @ticket 44405 + * @requires function imagejpeg */ public function test_edit_image_crop() { wp_set_current_user( self::$superadmin_id ); @@ -2118,6 +2150,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control /** * @ticket 50565 + * @requires function imagejpeg */ public function test_edit_image_returns_error_if_mismatched_src() { wp_set_current_user( self::$superadmin_id ); diff --git a/tests/phpunit/tests/url.php b/tests/phpunit/tests/url.php index 67240a73b4..0386bde6fc 100644 --- a/tests/phpunit/tests/url.php +++ b/tests/phpunit/tests/url.php @@ -273,10 +273,6 @@ class Tests_URL extends WP_UnitTestCase { } function test_set_url_scheme() { - if ( ! function_exists( 'set_url_scheme' ) ) { - return; - } - $links = array( 'http://wordpress.org/', 'https://wordpress.org/', diff --git a/tests/phpunit/tests/widgets/media-gallery-widget.php b/tests/phpunit/tests/widgets/media-gallery-widget.php index d3ca909bcb..1e67497833 100644 --- a/tests/phpunit/tests/widgets/media-gallery-widget.php +++ b/tests/phpunit/tests/widgets/media-gallery-widget.php @@ -52,6 +52,7 @@ class Test_WP_Widget_Media_Gallery extends WP_UnitTestCase { * Test update() method. * * @covers WP_Widget_Media_Gallery::render_media + * @requires function imagejpeg */ public function test_render_media() { $widget = new WP_Widget_Media_Gallery(); diff --git a/tests/phpunit/tests/widgets/media-widget.php b/tests/phpunit/tests/widgets/media-widget.php index 3877994ea3..ebe150d4f9 100644 --- a/tests/phpunit/tests/widgets/media-widget.php +++ b/tests/phpunit/tests/widgets/media-widget.php @@ -95,11 +95,8 @@ class Test_WP_Widget_Media extends WP_UnitTestCase { $this->assertSame( $id_base, $widget->id_base ); $this->assertSame( $name, $widget->name ); - // Method assertArraySubset doesn't exist in phpunit versions compatible with PHP 5.2. - if ( method_exists( $this, 'assertArraySubset' ) ) { - $this->assertArraySubset( $widget_options, $widget->widget_options ); - $this->assertArraySubset( $control_options, $widget->control_options ); - } + $this->assertArraySubset( $widget_options, $widget->widget_options ); + $this->assertArraySubset( $control_options, $widget->control_options ); } /** @@ -135,6 +132,7 @@ class Test_WP_Widget_Media extends WP_UnitTestCase { * Test is_attachment_with_mime_type method. * * @covers WP_Widget_Media::is_attachment_with_mime_type + * @requires function imagejpeg */ function test_is_attachment_with_mime_type() { diff --git a/tests/phpunit/tests/xmlrpc/mw/editPost.php b/tests/phpunit/tests/xmlrpc/mw/editPost.php index 271ad36f56..b20ee4a5c3 100644 --- a/tests/phpunit/tests/xmlrpc/mw/editPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/editPost.php @@ -132,6 +132,9 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $this->assertEquals( $editor_id, $out->post_author ); } + /** + * @requires function imagejpeg + */ function test_post_thumbnail() { add_theme_support( 'post-thumbnails' ); diff --git a/tests/phpunit/tests/xmlrpc/mw/getPost.php b/tests/phpunit/tests/xmlrpc/mw/getPost.php index 989f5c2290..fcdcdb3597 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/getPost.php @@ -89,6 +89,9 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { remove_theme_support( 'post-thumbnails' ); } + /** + * @requires function imagejpeg + */ function test_post_thumbnail() { add_theme_support( 'post-thumbnails' ); diff --git a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php index e6b00e5e42..8f5d52bb53 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php +++ b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php @@ -94,6 +94,9 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { remove_theme_support( 'post-thumbnails' ); } + /** + * @requires function imagejpeg + */ function test_post_thumbnail() { add_theme_support( 'post-thumbnails' ); diff --git a/tests/phpunit/tests/xmlrpc/mw/newPost.php b/tests/phpunit/tests/xmlrpc/mw/newPost.php index 456acbd31e..fcce8d0e66 100644 --- a/tests/phpunit/tests/xmlrpc/mw/newPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/newPost.php @@ -128,6 +128,9 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $this->assertSame( 'Test', $out->post_title ); } + /** + * @requires function imagejpeg + */ function test_post_thumbnail() { add_theme_support( 'post-thumbnails' ); diff --git a/tests/phpunit/tests/xmlrpc/wp/editPost.php b/tests/phpunit/tests/xmlrpc/wp/editPost.php index 8d732b1e64..ab3223fb7f 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/editPost.php @@ -132,6 +132,9 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $this->assertEquals( $editor_id, $out->post_author ); } + /** + * @requires function imagejpeg + */ function test_post_thumbnail() { add_theme_support( 'post-thumbnails' ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php b/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php index 39f31726b9..41dd0300dc 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php +++ b/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php @@ -2,6 +2,7 @@ /** * @group xmlrpc + * @requires function imagejpeg */ class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase { protected static $post_id; diff --git a/tests/phpunit/tests/xmlrpc/wp/newPost.php b/tests/phpunit/tests/xmlrpc/wp/newPost.php index 8fe16c12de..34afb87b77 100644 --- a/tests/phpunit/tests/xmlrpc/wp/newPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/newPost.php @@ -145,6 +145,9 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $this->assertSame( 'Test', $out->post_title ); } + /** + * @requires function imagejpeg + */ function test_post_thumbnail() { add_theme_support( 'post-thumbnails' ); diff --git a/tests/phpunit/tests/xmlrpc/wp/uploadFile.php b/tests/phpunit/tests/xmlrpc/wp/uploadFile.php index b9ba569a44..5098735bad 100644 --- a/tests/phpunit/tests/xmlrpc/wp/uploadFile.php +++ b/tests/phpunit/tests/xmlrpc/wp/uploadFile.php @@ -2,6 +2,7 @@ /** * @group xmlrpc + * @requires function imagejpeg */ class Tests_XMLRPC_wp_uploadFile extends WP_XMLRPC_UnitTestCase {