mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Tests: Clean up skipping conditions and requirements for various tests.
This improves the consistency of test skipping and ensures that: * The `@requires` annotations use the right condition and format, and are on the right level (class vs. function). * Inline conditions with a `markTestSkipped()` call are only used when annotations cannot be used. * All `markTestSkipped()` calls contain a verbose explanation of why the test is being skipped. Props jrf, hellofromTonya. Fixes #53009. git-svn-id: https://develop.svn.wordpress.org/trunk@51415 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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 );
|
||||
|
||||
@@ -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__;
|
||||
|
||||
@@ -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( '<xml><tag>1</tag><tag>2</tag></xml>' ) ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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( '' );
|
||||
|
||||
@@ -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 ) );
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
/**
|
||||
* @group http
|
||||
* @group external-http
|
||||
* @requires extension openssl
|
||||
*/
|
||||
class Tests_HTTP_Functions extends WP_UnitTestCase {
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* @group media
|
||||
* @group upload
|
||||
* @group resize
|
||||
*
|
||||
* @requires function imagejpeg
|
||||
*/
|
||||
require_once __DIR__ . '/resize.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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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/',
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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() {
|
||||
|
||||
|
||||
@@ -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' );
|
||||
|
||||
|
||||
@@ -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' );
|
||||
|
||||
|
||||
@@ -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' );
|
||||
|
||||
|
||||
@@ -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' );
|
||||
|
||||
|
||||
@@ -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' );
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
/**
|
||||
* @group xmlrpc
|
||||
* @requires function imagejpeg
|
||||
*/
|
||||
class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase {
|
||||
protected static $post_id;
|
||||
|
||||
@@ -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' );
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
/**
|
||||
* @group xmlrpc
|
||||
* @requires function imagejpeg
|
||||
*/
|
||||
class Tests_XMLRPC_wp_uploadFile extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user