mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-05 05:04:31 +00:00
Coding Standards: Add visibility to methods in tests/phpunit/tests/.
Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods. Adds a `private` visibility to helper methods within test classes. Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit. Props costdev, jrf, hellofromTonya. Fixes #54177. git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* @group functions.php
|
||||
*/
|
||||
class Tests_Functions extends WP_UnitTestCase {
|
||||
function test_wp_parse_args_object() {
|
||||
public function test_wp_parse_args_object() {
|
||||
$x = new MockClass;
|
||||
$x->_baba = 5;
|
||||
$x->yZ = 'baba'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
|
||||
@@ -21,7 +21,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$this->assertSame( array(), wp_parse_args( $y ) );
|
||||
}
|
||||
|
||||
function test_wp_parse_args_array() {
|
||||
public function test_wp_parse_args_array() {
|
||||
// Arrays.
|
||||
$a = array();
|
||||
$this->assertSame( array(), wp_parse_args( $a ) );
|
||||
@@ -40,7 +40,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function test_wp_parse_args_defaults() {
|
||||
public function test_wp_parse_args_defaults() {
|
||||
$x = new MockClass;
|
||||
$x->_baba = 5;
|
||||
$x->yZ = 'baba'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
|
||||
@@ -66,7 +66,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function test_wp_parse_args_other() {
|
||||
public function test_wp_parse_args_other() {
|
||||
$b = true;
|
||||
wp_parse_str( $b, $s );
|
||||
$this->assertSame( $s, wp_parse_args( $b ) );
|
||||
@@ -78,7 +78,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 30753
|
||||
*/
|
||||
function test_wp_parse_args_boolean_strings() {
|
||||
public function test_wp_parse_args_boolean_strings() {
|
||||
$args = wp_parse_args( 'foo=false&bar=true' );
|
||||
$this->assertIsString( $args['foo'] );
|
||||
$this->assertIsString( $args['bar'] );
|
||||
@@ -87,13 +87,13 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 35972
|
||||
*/
|
||||
function test_bool_from_yn() {
|
||||
public function test_bool_from_yn() {
|
||||
$this->assertTrue( bool_from_yn( 'Y' ) );
|
||||
$this->assertTrue( bool_from_yn( 'y' ) );
|
||||
$this->assertFalse( bool_from_yn( 'n' ) );
|
||||
}
|
||||
|
||||
function test_path_is_absolute() {
|
||||
public function test_path_is_absolute() {
|
||||
$absolute_paths = array(
|
||||
'/',
|
||||
'/foo/',
|
||||
@@ -111,7 +111,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function test_path_is_not_absolute() {
|
||||
public function test_path_is_not_absolute() {
|
||||
$relative_paths = array(
|
||||
'',
|
||||
'.',
|
||||
@@ -135,11 +135,11 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
*
|
||||
* @dataProvider data_wp_normalize_path
|
||||
*/
|
||||
function test_wp_normalize_path( $path, $expected ) {
|
||||
public function test_wp_normalize_path( $path, $expected ) {
|
||||
$this->assertSame( $expected, wp_normalize_path( $path ) );
|
||||
}
|
||||
|
||||
function data_wp_normalize_path() {
|
||||
public function data_wp_normalize_path() {
|
||||
return array(
|
||||
// Windows paths.
|
||||
array( 'C:\\www\\path\\', 'C:/www/path/' ),
|
||||
@@ -163,7 +163,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function test_wp_unique_filename() {
|
||||
public function test_wp_unique_filename() {
|
||||
|
||||
$testdir = DIR_TESTDATA . '/images/';
|
||||
|
||||
@@ -207,7 +207,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 42437
|
||||
*/
|
||||
function test_unique_filename_with_dimension_like_filename() {
|
||||
public function test_unique_filename_with_dimension_like_filename() {
|
||||
$testdir = DIR_TESTDATA . '/images/';
|
||||
|
||||
add_filter( 'upload_dir', array( $this, 'upload_dir_patch_basedir' ) );
|
||||
@@ -224,7 +224,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
// Callback to patch "basedir" when used in `wp_unique_filename()`.
|
||||
function upload_dir_patch_basedir( $upload_dir ) {
|
||||
public function upload_dir_patch_basedir( $upload_dir ) {
|
||||
$upload_dir['basedir'] = DIR_TESTDATA . '/images/';
|
||||
return $upload_dir;
|
||||
}
|
||||
@@ -232,7 +232,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 53668
|
||||
*/
|
||||
function test_wp_unique_filename_with_additional_image_extension() {
|
||||
public function test_wp_unique_filename_with_additional_image_extension() {
|
||||
$testdir = DIR_TESTDATA . '/images/';
|
||||
|
||||
add_filter( 'upload_dir', array( $this, 'upload_dir_patch_basedir' ) );
|
||||
@@ -314,7 +314,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data_is_not_serialized
|
||||
*/
|
||||
function test_maybe_serialize( $value ) {
|
||||
public function test_maybe_serialize( $value ) {
|
||||
if ( is_array( $value ) || is_object( $value ) ) {
|
||||
$expected = serialize( $value );
|
||||
} else {
|
||||
@@ -327,7 +327,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data_is_serialized
|
||||
*/
|
||||
function test_maybe_serialize_with_double_serialization( $value ) {
|
||||
public function test_maybe_serialize_with_double_serialization( $value ) {
|
||||
$expected = serialize( $value );
|
||||
|
||||
$this->assertSame( $expected, maybe_serialize( $value ) );
|
||||
@@ -337,7 +337,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @dataProvider data_is_serialized
|
||||
* @dataProvider data_is_not_serialized
|
||||
*/
|
||||
function test_maybe_unserialize( $value, $is_serialized ) {
|
||||
public function test_maybe_unserialize( $value, $is_serialized ) {
|
||||
if ( $is_serialized ) {
|
||||
$expected = unserialize( trim( $value ) );
|
||||
} else {
|
||||
@@ -355,14 +355,14 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @dataProvider data_is_serialized
|
||||
* @dataProvider data_is_not_serialized
|
||||
*/
|
||||
function test_is_serialized( $value, $expected ) {
|
||||
public function test_is_serialized( $value, $expected ) {
|
||||
$this->assertSame( $expected, is_serialized( $value ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_serialize_deserialize_objects
|
||||
*/
|
||||
function test_deserialize_request_utility_filtered_iterator_objects( $value ) {
|
||||
public function test_deserialize_request_utility_filtered_iterator_objects( $value ) {
|
||||
$serialized = maybe_serialize( $value );
|
||||
if ( get_class( $value ) === 'Requests_Utility_FilteredIterator' ) {
|
||||
$new_value = unserialize( $serialized );
|
||||
@@ -375,7 +375,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
function data_serialize_deserialize_objects() {
|
||||
public function data_serialize_deserialize_objects() {
|
||||
return array(
|
||||
array( new Requests_Utility_FilteredIterator( array( 1 ), 'md5' ) ),
|
||||
array( new Requests_Utility_FilteredIterator( array( 1, 2 ), 'sha1' ) ),
|
||||
@@ -383,7 +383,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function data_is_serialized() {
|
||||
public function data_is_serialized() {
|
||||
return array(
|
||||
array( serialize( null ), true ),
|
||||
array( serialize( true ), true ),
|
||||
@@ -409,7 +409,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function data_is_not_serialized() {
|
||||
public function data_is_not_serialized() {
|
||||
return array(
|
||||
array( null, false ),
|
||||
array( true, false ),
|
||||
@@ -439,11 +439,11 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @ticket 46570
|
||||
* @dataProvider data_is_serialized_should_return_true_for_large_floats
|
||||
*/
|
||||
function test_is_serialized_should_return_true_for_large_floats( $value ) {
|
||||
public function test_is_serialized_should_return_true_for_large_floats( $value ) {
|
||||
$this->assertTrue( is_serialized( $value ) );
|
||||
}
|
||||
|
||||
function data_is_serialized_should_return_true_for_large_floats() {
|
||||
public function data_is_serialized_should_return_true_for_large_floats() {
|
||||
return array(
|
||||
array( serialize( 1.7976931348623157E+308 ) ),
|
||||
array( serialize( array( 1.7976931348623157E+308, 1.23e50 ) ) ),
|
||||
@@ -453,14 +453,14 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 17375
|
||||
*/
|
||||
function test_no_new_serializable_types() {
|
||||
public function test_no_new_serializable_types() {
|
||||
$this->assertFalse( is_serialized( 'C:16:"Serialized_Class":6:{a:0:{}}' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @group add_query_arg
|
||||
*/
|
||||
function test_add_query_arg() {
|
||||
public function test_add_query_arg() {
|
||||
$old_req_uri = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$urls = array(
|
||||
@@ -648,7 +648,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 31306
|
||||
*/
|
||||
function test_add_query_arg_numeric_keys() {
|
||||
public function test_add_query_arg_numeric_keys() {
|
||||
$url = add_query_arg( array( 'foo' => 'bar' ), '1=1' );
|
||||
$this->assertSame( '1=1&foo=bar', $url );
|
||||
|
||||
@@ -668,7 +668,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21594
|
||||
*/
|
||||
function test_get_allowed_mime_types() {
|
||||
public function test_get_allowed_mime_types() {
|
||||
$mimes = get_allowed_mime_types();
|
||||
|
||||
$this->assertIsArray( $mimes );
|
||||
@@ -688,7 +688,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 21594
|
||||
*/
|
||||
function test_wp_get_mime_types() {
|
||||
public function test_wp_get_mime_types() {
|
||||
$mimes = wp_get_mime_types();
|
||||
|
||||
$this->assertIsArray( $mimes );
|
||||
@@ -720,7 +720,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 23688
|
||||
*/
|
||||
function test_canonical_charset() {
|
||||
public function test_canonical_charset() {
|
||||
$orig_blog_charset = get_option( 'blog_charset' );
|
||||
|
||||
update_option( 'blog_charset', 'utf8' );
|
||||
@@ -758,11 +758,11 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @ticket 43977
|
||||
* @dataProvider data_wp_parse_list
|
||||
*/
|
||||
function test_wp_parse_list( $expected, $actual ) {
|
||||
public function test_wp_parse_list( $expected, $actual ) {
|
||||
$this->assertSame( $expected, array_values( wp_parse_list( $actual ) ) );
|
||||
}
|
||||
|
||||
function data_wp_parse_list() {
|
||||
public function data_wp_parse_list() {
|
||||
return array(
|
||||
array( array( '1', '2', '3', '4' ), '1,2,3,4' ),
|
||||
array( array( 'apple', 'banana', 'carrot', 'dog' ), 'apple,banana,carrot,dog' ),
|
||||
@@ -781,11 +781,11 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data_wp_parse_id_list
|
||||
*/
|
||||
function test_wp_parse_id_list( $expected, $actual ) {
|
||||
public function test_wp_parse_id_list( $expected, $actual ) {
|
||||
$this->assertSame( $expected, array_values( wp_parse_id_list( $actual ) ) );
|
||||
}
|
||||
|
||||
function data_wp_parse_id_list() {
|
||||
public function data_wp_parse_id_list() {
|
||||
return array(
|
||||
array( array( 1, 2, 3, 4 ), '1,2,3,4' ),
|
||||
array( array( 1, 2, 3, 4 ), '1, 2,,3,4' ),
|
||||
@@ -800,11 +800,11 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data_wp_parse_slug_list
|
||||
*/
|
||||
function test_wp_parse_slug_list( $expected, $actual ) {
|
||||
public function test_wp_parse_slug_list( $expected, $actual ) {
|
||||
$this->assertSame( $expected, array_values( wp_parse_slug_list( $actual ) ) );
|
||||
}
|
||||
|
||||
function data_wp_parse_slug_list() {
|
||||
public function data_wp_parse_slug_list() {
|
||||
return array(
|
||||
array( array( 'apple', 'banana', 'carrot', 'dog' ), 'apple,banana,carrot,dog' ),
|
||||
array( array( 'apple', 'banana', 'carrot', 'dog' ), 'apple, banana,,carrot,dog' ),
|
||||
@@ -816,14 +816,14 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @dataProvider data_device_can_upload
|
||||
*/
|
||||
function test_device_can_upload( $user_agent, $expected ) {
|
||||
public function test_device_can_upload( $user_agent, $expected ) {
|
||||
$_SERVER['HTTP_USER_AGENT'] = $user_agent;
|
||||
$actual = _device_can_upload();
|
||||
unset( $_SERVER['HTTP_USER_AGENT'] );
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
function data_device_can_upload() {
|
||||
public function data_device_can_upload() {
|
||||
return array(
|
||||
// iPhone iOS 5.0.1, Safari 5.1.
|
||||
array(
|
||||
@@ -876,7 +876,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 9064
|
||||
*/
|
||||
function test_wp_extract_urls() {
|
||||
public function test_wp_extract_urls() {
|
||||
$original_urls = array(
|
||||
'http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html',
|
||||
'http://this.com',
|
||||
@@ -1043,14 +1043,14 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 28786
|
||||
*/
|
||||
function test_wp_json_encode() {
|
||||
public function test_wp_json_encode() {
|
||||
$this->assertSame( wp_json_encode( 'a' ), '"a"' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 28786
|
||||
*/
|
||||
function test_wp_json_encode_utf8() {
|
||||
public function test_wp_json_encode_utf8() {
|
||||
$this->assertSame( wp_json_encode( '这' ), '"\u8fd9"' );
|
||||
}
|
||||
|
||||
@@ -1058,7 +1058,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @ticket 28786
|
||||
* @requires function mb_detect_order
|
||||
*/
|
||||
function test_wp_json_encode_non_utf8() {
|
||||
public function test_wp_json_encode_non_utf8() {
|
||||
$charsets = mb_detect_order();
|
||||
$old_charsets = $charsets;
|
||||
if ( ! in_array( 'EUC-JP', $charsets, true ) ) {
|
||||
@@ -1080,7 +1080,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @ticket 28786
|
||||
* @requires function mb_detect_order
|
||||
*/
|
||||
function test_wp_json_encode_non_utf8_in_array() {
|
||||
public function test_wp_json_encode_non_utf8_in_array() {
|
||||
$charsets = mb_detect_order();
|
||||
$old_charsets = $charsets;
|
||||
if ( ! in_array( 'EUC-JP', $charsets, true ) ) {
|
||||
@@ -1101,14 +1101,14 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 28786
|
||||
*/
|
||||
function test_wp_json_encode_array() {
|
||||
public function test_wp_json_encode_array() {
|
||||
$this->assertSame( wp_json_encode( array( 'a' ) ), '["a"]' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 28786
|
||||
*/
|
||||
function test_wp_json_encode_object() {
|
||||
public function test_wp_json_encode_object() {
|
||||
$object = new stdClass;
|
||||
$object->a = 'b';
|
||||
$this->assertSame( wp_json_encode( $object ), '{"a":"b"}' );
|
||||
@@ -1117,7 +1117,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 28786
|
||||
*/
|
||||
function test_wp_json_encode_depth() {
|
||||
public function test_wp_json_encode_depth() {
|
||||
$data = array( array( array( 1, 2, 3 ) ) );
|
||||
$json = wp_json_encode( $data, 0, 1 );
|
||||
$this->assertFalse( $json );
|
||||
@@ -1130,7 +1130,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 53238
|
||||
*/
|
||||
function test_wp_json_file_decode() {
|
||||
public function test_wp_json_file_decode() {
|
||||
$result = wp_json_file_decode(
|
||||
DIR_TESTDATA . '/blocks/notice/block.json'
|
||||
);
|
||||
@@ -1142,7 +1142,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* @ticket 53238
|
||||
*/
|
||||
function test_wp_json_file_decode_associative_array() {
|
||||
public function test_wp_json_file_decode_associative_array() {
|
||||
$result = wp_json_file_decode(
|
||||
DIR_TESTDATA . '/blocks/notice/block.json',
|
||||
array( 'associative' => true )
|
||||
@@ -1156,7 +1156,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @ticket 36054
|
||||
* @dataProvider datetime_provider
|
||||
*/
|
||||
function test_mysql_to_rfc3339( $expected, $actual ) {
|
||||
public function test_mysql_to_rfc3339( $expected, $actual ) {
|
||||
$date_return = mysql_to_rfc3339( $actual );
|
||||
|
||||
$this->assertIsString( $date_return, 'The date return must be a string' );
|
||||
@@ -1165,7 +1165,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$this->assertEquals( new DateTime( $expected ), new DateTime( $date_return ), 'The date is not the same after the call method' );
|
||||
}
|
||||
|
||||
function datetime_provider() {
|
||||
public function datetime_provider() {
|
||||
return array(
|
||||
array( '2016-03-15T18:54:46', '15-03-2016 18:54:46' ),
|
||||
array( '2016-03-02T19:13:25', '2016-03-02 19:13:25' ),
|
||||
@@ -1218,7 +1218,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 32075
|
||||
*/
|
||||
function test_wp_raise_memory_limit() {
|
||||
public function test_wp_raise_memory_limit() {
|
||||
if ( -1 !== WP_MAX_MEMORY_LIMIT ) {
|
||||
$this->markTestSkipped( 'WP_MAX_MEMORY_LIMIT should be set to -1.' );
|
||||
}
|
||||
@@ -1238,7 +1238,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @covers ::wp_generate_uuid4
|
||||
* @ticket 38164
|
||||
*/
|
||||
function test_wp_generate_uuid4() {
|
||||
public function test_wp_generate_uuid4() {
|
||||
$uuids = array();
|
||||
for ( $i = 0; $i < 20; $i += 1 ) {
|
||||
$uuid = wp_generate_uuid4();
|
||||
@@ -1256,7 +1256,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @covers ::wp_is_uuid
|
||||
* @ticket 39778
|
||||
*/
|
||||
function test_wp_is_valid_uuid() {
|
||||
public function test_wp_is_valid_uuid() {
|
||||
$uuids_v4 = array(
|
||||
'27fe2421-780c-44c5-b39b-fff753092b55',
|
||||
'b7c7713a-4ee9-45a1-87ed-944a90390fc7',
|
||||
@@ -1306,7 +1306,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @covers ::wp_unique_id
|
||||
* @ticket 44883
|
||||
*/
|
||||
function test_wp_unique_id() {
|
||||
public function test_wp_unique_id() {
|
||||
|
||||
// Test without prefix.
|
||||
$ids = array();
|
||||
@@ -1330,7 +1330,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 40017
|
||||
* @dataProvider _wp_get_image_mime
|
||||
* @dataProvider wp_get_image_mime
|
||||
*/
|
||||
public function test_wp_get_image_mime( $file, $expected ) {
|
||||
if ( ! is_callable( 'exif_imagetype' ) && ! function_exists( 'getimagesize' ) ) {
|
||||
@@ -1365,10 +1365,10 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 39550
|
||||
* @dataProvider _wp_check_filetype_and_ext_data
|
||||
* @dataProvider wp_check_filetype_and_ext_data
|
||||
* @requires extension fileinfo
|
||||
*/
|
||||
function test_wp_check_filetype_and_ext( $file, $filename, $expected ) {
|
||||
public function test_wp_check_filetype_and_ext( $file, $filename, $expected ) {
|
||||
$this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) );
|
||||
}
|
||||
|
||||
@@ -1377,7 +1377,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @group ms-excluded
|
||||
* @requires extension fileinfo
|
||||
*/
|
||||
function test_wp_check_filetype_and_ext_with_filtered_svg() {
|
||||
public function test_wp_check_filetype_and_ext_with_filtered_svg() {
|
||||
$file = DIR_TESTDATA . '/uploads/video-play.svg';
|
||||
$filename = 'video-play.svg';
|
||||
|
||||
@@ -1387,11 +1387,11 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
'proper_filename' => false,
|
||||
);
|
||||
|
||||
add_filter( 'upload_mimes', array( $this, '_filter_mime_types_svg' ) );
|
||||
add_filter( 'upload_mimes', array( $this, 'filter_mime_types_svg' ) );
|
||||
$this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) );
|
||||
|
||||
// Cleanup.
|
||||
remove_filter( 'upload_mimes', array( $this, '_test_add_mime_types_svg' ) );
|
||||
remove_filter( 'upload_mimes', array( $this, 'filter_mime_types_svg' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1399,7 +1399,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @group ms-excluded
|
||||
* @requires extension fileinfo
|
||||
*/
|
||||
function test_wp_check_filetype_and_ext_with_filtered_woff() {
|
||||
public function test_wp_check_filetype_and_ext_with_filtered_woff() {
|
||||
$file = DIR_TESTDATA . '/uploads/dashicons.woff';
|
||||
$filename = 'dashicons.woff';
|
||||
|
||||
@@ -1409,19 +1409,19 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
'proper_filename' => false,
|
||||
);
|
||||
|
||||
add_filter( 'upload_mimes', array( $this, '_filter_mime_types_woff' ) );
|
||||
add_filter( 'upload_mimes', array( $this, 'filter_mime_types_woff' ) );
|
||||
$this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) );
|
||||
|
||||
// Cleanup.
|
||||
remove_filter( 'upload_mimes', array( $this, '_test_add_mime_types_woff' ) );
|
||||
remove_filter( 'upload_mimes', array( $this, 'filter_mime_types_woff' ) );
|
||||
}
|
||||
|
||||
public function _filter_mime_types_svg( $mimes ) {
|
||||
public function filter_mime_types_svg( $mimes ) {
|
||||
$mimes['svg'] = 'image/svg+xml';
|
||||
return $mimes;
|
||||
}
|
||||
|
||||
public function _filter_mime_types_woff( $mimes ) {
|
||||
public function filter_mime_types_woff( $mimes ) {
|
||||
$mimes['woff'] = 'application/font-woff';
|
||||
return $mimes;
|
||||
}
|
||||
@@ -1429,7 +1429,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
/**
|
||||
* Data provider for test_wp_get_image_mime().
|
||||
*/
|
||||
public function _wp_get_image_mime() {
|
||||
public function wp_get_image_mime() {
|
||||
$data = array(
|
||||
// Standard JPEG.
|
||||
array(
|
||||
@@ -1584,7 +1584,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function _wp_check_filetype_and_ext_data() {
|
||||
public function wp_check_filetype_and_ext_data() {
|
||||
$data = array(
|
||||
// Standard image.
|
||||
array(
|
||||
|
||||
Reference in New Issue
Block a user