mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 21:00:21 +00:00
Code is Poetry.
WordPress' code just... wasn't. This is now dealt with. Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS. Fixes #41057. git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
+254
-122
@@ -5,41 +5,70 @@
|
||||
*/
|
||||
class Tests_Functions extends WP_UnitTestCase {
|
||||
function test_wp_parse_args_object() {
|
||||
$x = new MockClass;
|
||||
$x = new MockClass;
|
||||
$x->_baba = 5;
|
||||
$x->yZ = "baba";
|
||||
$x->a = array(5, 111, 'x');
|
||||
$this->assertEquals(array('_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x')), wp_parse_args($x));
|
||||
$x->yZ = 'baba';
|
||||
$x->a = array( 5, 111, 'x' );
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'_baba' => 5,
|
||||
'yZ' => 'baba',
|
||||
'a' => array( 5, 111, 'x' ),
|
||||
), wp_parse_args( $x )
|
||||
);
|
||||
$y = new MockClass;
|
||||
$this->assertEquals(array(), wp_parse_args($y));
|
||||
$this->assertEquals( array(), wp_parse_args( $y ) );
|
||||
}
|
||||
|
||||
function test_wp_parse_args_array() {
|
||||
function test_wp_parse_args_array() {
|
||||
// arrays
|
||||
$a = array();
|
||||
$this->assertEquals(array(), wp_parse_args($a));
|
||||
$b = array('_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x'));
|
||||
$this->assertEquals(array('_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x')), wp_parse_args($b));
|
||||
$this->assertEquals( array(), wp_parse_args( $a ) );
|
||||
$b = array(
|
||||
'_baba' => 5,
|
||||
'yZ' => 'baba',
|
||||
'a' => array( 5, 111, 'x' ),
|
||||
);
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'_baba' => 5,
|
||||
'yZ' => 'baba',
|
||||
'a' => array( 5, 111, 'x' ),
|
||||
), wp_parse_args( $b )
|
||||
);
|
||||
}
|
||||
|
||||
function test_wp_parse_args_defaults() {
|
||||
$x = new MockClass;
|
||||
$x = new MockClass;
|
||||
$x->_baba = 5;
|
||||
$x->yZ = "baba";
|
||||
$x->a = array(5, 111, 'x');
|
||||
$d = array('pu' => 'bu');
|
||||
$this->assertEquals(array('pu' => 'bu', '_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x')), wp_parse_args($x, $d));
|
||||
$e = array('_baba' => 6);
|
||||
$this->assertEquals(array('_baba' => 5, 'yZ' => 'baba', 'a' => array(5, 111, 'x')), wp_parse_args($x, $e));
|
||||
$x->yZ = 'baba';
|
||||
$x->a = array( 5, 111, 'x' );
|
||||
$d = array( 'pu' => 'bu' );
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'pu' => 'bu',
|
||||
'_baba' => 5,
|
||||
'yZ' => 'baba',
|
||||
'a' => array( 5, 111, 'x' ),
|
||||
), wp_parse_args( $x, $d )
|
||||
);
|
||||
$e = array( '_baba' => 6 );
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'_baba' => 5,
|
||||
'yZ' => 'baba',
|
||||
'a' => array( 5, 111, 'x' ),
|
||||
), wp_parse_args( $x, $e )
|
||||
);
|
||||
}
|
||||
|
||||
function test_wp_parse_args_other() {
|
||||
$b = true;
|
||||
wp_parse_str($b, $s);
|
||||
$this->assertEquals($s, wp_parse_args($b));
|
||||
wp_parse_str( $b, $s );
|
||||
$this->assertEquals( $s, wp_parse_args( $b ) );
|
||||
$q = 'x=5&_baba=dudu&';
|
||||
wp_parse_str($q, $ss);
|
||||
$this->assertEquals($ss, wp_parse_args($q));
|
||||
wp_parse_str( $q, $ss );
|
||||
$this->assertEquals( $ss, wp_parse_args( $q ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,9 +101,10 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
'C:\\',
|
||||
'C:\\WINDOWS',
|
||||
'\\\\sambashare\\foo',
|
||||
);
|
||||
foreach ($absolute_paths as $path)
|
||||
$this->assertTrue( path_is_absolute($path), "path_is_absolute('$path') should return true" );
|
||||
);
|
||||
foreach ( $absolute_paths as $path ) {
|
||||
$this->assertTrue( path_is_absolute( $path ), "path_is_absolute('$path') should return true" );
|
||||
}
|
||||
}
|
||||
|
||||
function test_path_is_not_absolute() {
|
||||
@@ -89,9 +119,10 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
'foo',
|
||||
'FOO',
|
||||
'..\\WINDOWS',
|
||||
);
|
||||
foreach ($relative_paths as $path)
|
||||
$this->assertFalse( path_is_absolute($path), "path_is_absolute('$path') should return false" );
|
||||
);
|
||||
foreach ( $relative_paths as $path ) {
|
||||
$this->assertFalse( path_is_absolute( $path ), "path_is_absolute('$path') should return false" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,10 +172,10 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$this->assertEquals( 'tést-imagé.png', wp_unique_filename( $testdir, 'tést-imagé.png' ), 'Filename with special chars failed' );
|
||||
|
||||
// check with single quotes in name (somehow)
|
||||
$this->assertEquals( "abcdefgh.png", wp_unique_filename( $testdir, "abcdefg'h.png" ), 'File with quote failed' );
|
||||
$this->assertEquals( 'abcdefgh.png', wp_unique_filename( $testdir, "abcdefg'h.png" ), 'File with quote failed' );
|
||||
|
||||
// check with single quotes in name (somehow)
|
||||
$this->assertEquals( "abcdefgh.png", wp_unique_filename( $testdir, 'abcdefg"h.png' ), 'File with quote failed' );
|
||||
$this->assertEquals( 'abcdefgh.png', wp_unique_filename( $testdir, 'abcdefg"h.png' ), 'File with quote failed' );
|
||||
|
||||
// test crazy name (useful for regression tests)
|
||||
$this->assertEquals( '12af34567890@..^_qwerty-fghjkl-zx.png', wp_unique_filename( $testdir, '12%af34567890#~!@#$..%^&*()|_+qwerty fgh`jkl zx<>?:"{}[]="\'/?.png' ), 'Failed crazy file name' );
|
||||
@@ -157,28 +188,36 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
|
||||
function test_is_serialized() {
|
||||
$cases = array(
|
||||
serialize(null),
|
||||
serialize(true),
|
||||
serialize(false),
|
||||
serialize(-25),
|
||||
serialize(25),
|
||||
serialize(1.1),
|
||||
serialize('this string will be serialized'),
|
||||
serialize("a\nb"),
|
||||
serialize(array()),
|
||||
serialize(array(1,1,2,3,5,8,13)),
|
||||
serialize( (object)array('test' => true, '3', 4) )
|
||||
serialize( null ),
|
||||
serialize( true ),
|
||||
serialize( false ),
|
||||
serialize( -25 ),
|
||||
serialize( 25 ),
|
||||
serialize( 1.1 ),
|
||||
serialize( 'this string will be serialized' ),
|
||||
serialize( "a\nb" ),
|
||||
serialize( array() ),
|
||||
serialize( array( 1, 1, 2, 3, 5, 8, 13 ) ),
|
||||
serialize(
|
||||
(object) array(
|
||||
'test' => true,
|
||||
'3',
|
||||
4,
|
||||
)
|
||||
),
|
||||
);
|
||||
foreach ( $cases as $case )
|
||||
$this->assertTrue( is_serialized($case), "Serialized data: $case" );
|
||||
foreach ( $cases as $case ) {
|
||||
$this->assertTrue( is_serialized( $case ), "Serialized data: $case" );
|
||||
}
|
||||
|
||||
$not_serialized = array(
|
||||
'a string',
|
||||
'garbage:a:0:garbage;',
|
||||
's:4:test;'
|
||||
's:4:test;',
|
||||
);
|
||||
foreach ( $not_serialized as $case )
|
||||
$this->assertFalse( is_serialized($case), "Test data: $case" );
|
||||
foreach ( $not_serialized as $case ) {
|
||||
$this->assertFalse( is_serialized( $case ), "Test data: $case" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,32 +293,88 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
|
||||
$this->assertEquals( "$url?foo=1", add_query_arg( 'foo', '1', $url ) );
|
||||
$this->assertEquals( "$url?foo=1", add_query_arg( array( 'foo' => '1' ), $url ) );
|
||||
$this->assertEquals( "$url?foo=2", add_query_arg( array( 'foo' => '1', 'foo' => '2' ), $url ) );
|
||||
$this->assertEquals( "$url?foo=1&bar=2", add_query_arg( array( 'foo' => '1', 'bar' => '2' ), $url ) );
|
||||
$this->assertEquals(
|
||||
"$url?foo=2", add_query_arg(
|
||||
array(
|
||||
'foo' => '1',
|
||||
'foo' => '2',
|
||||
), $url
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
"$url?foo=1&bar=2", add_query_arg(
|
||||
array(
|
||||
'foo' => '1',
|
||||
'bar' => '2',
|
||||
), $url
|
||||
)
|
||||
);
|
||||
|
||||
$_SERVER['REQUEST_URI'] = $url;
|
||||
|
||||
$this->assertEquals( "$url?foo=1", add_query_arg( 'foo', '1' ) );
|
||||
$this->assertEquals( "$url?foo=1", add_query_arg( array( 'foo' => '1' ) ) );
|
||||
$this->assertEquals( "$url?foo=2", add_query_arg( array( 'foo' => '1', 'foo' => '2' ) ) );
|
||||
$this->assertEquals( "$url?foo=1&bar=2", add_query_arg( array( 'foo' => '1', 'bar' => '2' ) ) );
|
||||
$this->assertEquals(
|
||||
"$url?foo=2", add_query_arg(
|
||||
array(
|
||||
'foo' => '1',
|
||||
'foo' => '2',
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
"$url?foo=1&bar=2", add_query_arg(
|
||||
array(
|
||||
'foo' => '1',
|
||||
'bar' => '2',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
foreach ( $frag_urls as $frag_url ) {
|
||||
$_SERVER['REQUEST_URI'] = 'nothing';
|
||||
$url = str_replace( '#frag', '', $frag_url );
|
||||
$url = str_replace( '#frag', '', $frag_url );
|
||||
|
||||
$this->assertEquals( "$url?foo=1#frag", add_query_arg( 'foo', '1', $frag_url ) );
|
||||
$this->assertEquals( "$url?foo=1#frag", add_query_arg( array( 'foo' => '1' ), $frag_url ) );
|
||||
$this->assertEquals( "$url?foo=2#frag", add_query_arg( array( 'foo' => '1', 'foo' => '2' ), $frag_url ) );
|
||||
$this->assertEquals( "$url?foo=1&bar=2#frag", add_query_arg( array( 'foo' => '1', 'bar' => '2' ), $frag_url ) );
|
||||
$this->assertEquals(
|
||||
"$url?foo=2#frag", add_query_arg(
|
||||
array(
|
||||
'foo' => '1',
|
||||
'foo' => '2',
|
||||
), $frag_url
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
"$url?foo=1&bar=2#frag", add_query_arg(
|
||||
array(
|
||||
'foo' => '1',
|
||||
'bar' => '2',
|
||||
), $frag_url
|
||||
)
|
||||
);
|
||||
|
||||
$_SERVER['REQUEST_URI'] = $frag_url;
|
||||
|
||||
$this->assertEquals( "$url?foo=1#frag", add_query_arg( 'foo', '1' ) );
|
||||
$this->assertEquals( "$url?foo=1#frag", add_query_arg( array( 'foo' => '1' ) ) );
|
||||
$this->assertEquals( "$url?foo=2#frag", add_query_arg( array( 'foo' => '1', 'foo' => '2' ) ) );
|
||||
$this->assertEquals( "$url?foo=1&bar=2#frag", add_query_arg( array( 'foo' => '1', 'bar' => '2' ) ) );
|
||||
$this->assertEquals(
|
||||
"$url?foo=2#frag", add_query_arg(
|
||||
array(
|
||||
'foo' => '1',
|
||||
'foo' => '2',
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
"$url?foo=1&bar=2#frag", add_query_arg(
|
||||
array(
|
||||
'foo' => '1',
|
||||
'bar' => '2',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$qs_urls = array(
|
||||
@@ -299,15 +394,43 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
|
||||
$this->assertEquals( "$url&foo=1", add_query_arg( 'foo', '1', $url ) );
|
||||
$this->assertEquals( "$url&foo=1", add_query_arg( array( 'foo' => '1' ), $url ) );
|
||||
$this->assertEquals( "$url&foo=2", add_query_arg( array( 'foo' => '1', 'foo' => '2' ), $url ) );
|
||||
$this->assertEquals( "$url&foo=1&bar=2", add_query_arg( array( 'foo' => '1', 'bar' => '2' ), $url ) );
|
||||
$this->assertEquals(
|
||||
"$url&foo=2", add_query_arg(
|
||||
array(
|
||||
'foo' => '1',
|
||||
'foo' => '2',
|
||||
), $url
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
"$url&foo=1&bar=2", add_query_arg(
|
||||
array(
|
||||
'foo' => '1',
|
||||
'bar' => '2',
|
||||
), $url
|
||||
)
|
||||
);
|
||||
|
||||
$_SERVER['REQUEST_URI'] = $url;
|
||||
|
||||
$this->assertEquals( "$url&foo=1", add_query_arg( 'foo', '1' ) );
|
||||
$this->assertEquals( "$url&foo=1", add_query_arg( array( 'foo' => '1' ) ) );
|
||||
$this->assertEquals( "$url&foo=2", add_query_arg( array( 'foo' => '1', 'foo' => '2' ) ) );
|
||||
$this->assertEquals( "$url&foo=1&bar=2", add_query_arg( array( 'foo' => '1', 'bar' => '2' ) ) );
|
||||
$this->assertEquals(
|
||||
"$url&foo=2", add_query_arg(
|
||||
array(
|
||||
'foo' => '1',
|
||||
'foo' => '2',
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->assertEquals(
|
||||
"$url&foo=1&bar=2", add_query_arg(
|
||||
array(
|
||||
'foo' => '1',
|
||||
'bar' => '2',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$_SERVER['REQUEST_URI'] = $old_req_uri;
|
||||
@@ -318,13 +441,18 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_add_query_arg_numeric_keys() {
|
||||
$url = add_query_arg( array( 'foo' => 'bar' ), '1=1' );
|
||||
$this->assertEquals('1=1&foo=bar', $url);
|
||||
$this->assertEquals( '1=1&foo=bar', $url );
|
||||
|
||||
$url = add_query_arg( array( 'foo' => 'bar', '1' => '2' ), '1=1' );
|
||||
$this->assertEquals('1=2&foo=bar', $url);
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'foo' => 'bar',
|
||||
'1' => '2',
|
||||
), '1=1'
|
||||
);
|
||||
$this->assertEquals( '1=2&foo=bar', $url );
|
||||
|
||||
$url = add_query_arg( array( '1' => '2' ), 'foo=bar' );
|
||||
$this->assertEquals('foo=bar&1=2', $url);
|
||||
$this->assertEquals( 'foo=bar&1=2', $url );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -386,32 +514,32 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$orig_blog_charset = get_option( 'blog_charset' );
|
||||
|
||||
update_option( 'blog_charset', 'utf8' );
|
||||
$this->assertEquals( 'UTF-8', get_option( 'blog_charset') );
|
||||
$this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) );
|
||||
|
||||
update_option( 'blog_charset', 'utf-8' );
|
||||
$this->assertEquals( 'UTF-8', get_option( 'blog_charset') );
|
||||
$this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) );
|
||||
|
||||
update_option( 'blog_charset', 'UTF8' );
|
||||
$this->assertEquals( 'UTF-8', get_option( 'blog_charset') );
|
||||
$this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) );
|
||||
|
||||
update_option( 'blog_charset', 'UTF-8' );
|
||||
$this->assertEquals( 'UTF-8', get_option( 'blog_charset') );
|
||||
$this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) );
|
||||
|
||||
update_option( 'blog_charset', 'ISO-8859-1' );
|
||||
$this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset') );
|
||||
$this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) );
|
||||
|
||||
update_option( 'blog_charset', 'ISO8859-1' );
|
||||
$this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset') );
|
||||
$this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) );
|
||||
|
||||
update_option( 'blog_charset', 'iso8859-1' );
|
||||
$this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset') );
|
||||
$this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) );
|
||||
|
||||
update_option( 'blog_charset', 'iso-8859-1' );
|
||||
$this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset') );
|
||||
$this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) );
|
||||
|
||||
// Arbitrary strings are passed through.
|
||||
update_option( 'blog_charset', 'foobarbaz' );
|
||||
$this->assertEquals( 'foobarbaz', get_option( 'blog_charset') );
|
||||
$this->assertEquals( 'foobarbaz', get_option( 'blog_charset' ) );
|
||||
|
||||
update_option( 'blog_charset', $orig_blog_charset );
|
||||
}
|
||||
@@ -456,7 +584,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_device_can_upload( $user_agent, $expected ) {
|
||||
$_SERVER['HTTP_USER_AGENT'] = $user_agent;
|
||||
$actual = _device_can_upload();
|
||||
$actual = _device_can_upload();
|
||||
unset( $_SERVER['HTTP_USER_AGENT'] );
|
||||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
@@ -571,10 +699,10 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
'http://việtnam.icom.museum',
|
||||
'ftp://127.0.0.1/',
|
||||
'http://www.woo.com/video?v=exvUH2qKLTU',
|
||||
'http://taco.com?burrito=enchilada#guac'
|
||||
'http://taco.com?burrito=enchilada#guac',
|
||||
);
|
||||
|
||||
$blob ="
|
||||
$blob = '
|
||||
http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html
|
||||
|
||||
http://this.com
|
||||
@@ -634,7 +762,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
http://www.woo.com/video?v=exvUH2qKLTU
|
||||
|
||||
http://taco.com?burrito=enchilada#guac
|
||||
";
|
||||
';
|
||||
|
||||
$urls = wp_extract_urls( $blob );
|
||||
$this->assertNotEmpty( $urls );
|
||||
@@ -649,13 +777,13 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$this->assertEquals( $decoded, $urls );
|
||||
$this->assertEquals( $original_urls, $decoded );
|
||||
|
||||
$blob ="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
|
||||
$blob = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
|
||||
incididunt ut labore http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html et dolore magna aliqua.
|
||||
Ut http://this.com enim ad minim veniam, quis nostrud exercitation 16.06. to 18.06.2014 ullamco http://127.0.0.1
|
||||
laboris nisi ut aliquip ex http://www111.urwyeoweytwutreyytqytwetowteuiiu.com/?346236346326&2134362574863.437 ea
|
||||
commodo consequat. http://wordpress-core/1,2,3,4,5,6/-1-2-3-4-/woo.html Duis aute irure dolor in reprehenderit in voluptate
|
||||
velit esse http://wordpress-core.com:8080/ cillum dolore eu fugiat nulla <A href=\"http://www.website.com:5000\">http://www.website.com:5000</B> pariatur. Excepteur sint occaecat cupidatat non proident,
|
||||
sunt in culpa qui officia deserunt mollit http://wordpress-core/?346236346326&2134362574863.437 anim id est laborum.";
|
||||
velit esse http://wordpress-core.com:8080/ cillum dolore eu fugiat nulla <A href="http://www.website.com:5000">http://www.website.com:5000</B> pariatur. Excepteur sint occaecat cupidatat non proident,
|
||||
sunt in culpa qui officia deserunt mollit http://wordpress-core/?346236346326&2134362574863.437 anim id est laborum.';
|
||||
|
||||
$urls = wp_extract_urls( $blob );
|
||||
$this->assertNotEmpty( $urls );
|
||||
@@ -707,7 +835,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
$eucjp = mb_convert_encoding( 'aあb', 'EUC-JP', 'UTF-8' );
|
||||
$utf8 = mb_convert_encoding( $eucjp, 'UTF-8', 'EUC-JP' );
|
||||
$utf8 = mb_convert_encoding( $eucjp, 'UTF-8', 'EUC-JP' );
|
||||
|
||||
$this->assertEquals( 'aあb', $utf8 );
|
||||
|
||||
@@ -731,7 +859,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
$eucjp = mb_convert_encoding( 'aあb', 'EUC-JP', 'UTF-8' );
|
||||
$utf8 = mb_convert_encoding( $eucjp, 'UTF-8', 'EUC-JP' );
|
||||
$utf8 = mb_convert_encoding( $eucjp, 'UTF-8', 'EUC-JP' );
|
||||
|
||||
$this->assertEquals( 'aあb', $utf8 );
|
||||
|
||||
@@ -751,7 +879,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
* @ticket 28786
|
||||
*/
|
||||
function test_wp_json_encode_object() {
|
||||
$object = new stdClass;
|
||||
$object = new stdClass;
|
||||
$object->a = 'b';
|
||||
$this->assertEquals( wp_json_encode( $object ), '{"a":"b"}' );
|
||||
}
|
||||
@@ -782,9 +910,11 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$actual = ob_get_clean();
|
||||
$this->assertEquals( '', $actual );
|
||||
|
||||
$GLOBALS['post'] = self::factory()->post->create_and_get( array(
|
||||
'post_date' => '2015-09-16 08:00:00'
|
||||
) );
|
||||
$GLOBALS['post'] = self::factory()->post->create_and_get(
|
||||
array(
|
||||
'post_date' => '2015-09-16 08:00:00',
|
||||
)
|
||||
);
|
||||
|
||||
ob_start();
|
||||
$GLOBALS['currentday'] = '18.09.15';
|
||||
@@ -830,7 +960,7 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
array( '2016-03-02T19:13:25', '2016-03-02 19:13:25' ),
|
||||
array( '2016-03-02T19:13:00', '2016-03-02 19:13' ),
|
||||
array( '2016-03-02T19:13:00', '16-03-02 19:13' ),
|
||||
array( '2016-03-02T19:13:00', '16-03-02 19:13' )
|
||||
array( '2016-03-02T19:13:00', '16-03-02 19:13' ),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -883,8 +1013,8 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
$ini_limit_before = ini_get( 'memory_limit' );
|
||||
$raised_limit = wp_raise_memory_limit();
|
||||
$ini_limit_after = ini_get( 'memory_limit' );
|
||||
$raised_limit = wp_raise_memory_limit();
|
||||
$ini_limit_after = ini_get( 'memory_limit' );
|
||||
|
||||
$this->assertSame( $ini_limit_before, $ini_limit_after );
|
||||
$this->assertSame( false, $raised_limit );
|
||||
@@ -992,12 +1122,12 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
|
||||
}
|
||||
|
||||
$file = DIR_TESTDATA . '/uploads/video-play.svg';
|
||||
$file = DIR_TESTDATA . '/uploads/video-play.svg';
|
||||
$filename = 'video-play.svg';
|
||||
|
||||
$expected = array(
|
||||
'ext' => 'svg',
|
||||
'type' => 'image/svg+xml',
|
||||
'ext' => 'svg',
|
||||
'type' => 'image/svg+xml',
|
||||
'proper_filename' => false,
|
||||
);
|
||||
|
||||
@@ -1017,12 +1147,12 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
$this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' );
|
||||
}
|
||||
|
||||
$file = DIR_TESTDATA . '/uploads/dashicons.woff';
|
||||
$file = DIR_TESTDATA . '/uploads/dashicons.woff';
|
||||
$filename = 'dashicons.woff';
|
||||
|
||||
$expected = array(
|
||||
'ext' => 'woff',
|
||||
'type' => 'application/font-woff',
|
||||
'ext' => 'woff',
|
||||
'type' => 'application/font-woff',
|
||||
'proper_filename' => false,
|
||||
);
|
||||
|
||||
@@ -1085,8 +1215,8 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
DIR_TESTDATA . '/images/canola.jpg',
|
||||
'canola.jpg',
|
||||
array(
|
||||
'ext' => 'jpg',
|
||||
'type' => 'image/jpeg',
|
||||
'ext' => 'jpg',
|
||||
'type' => 'image/jpeg',
|
||||
'proper_filename' => false,
|
||||
),
|
||||
),
|
||||
@@ -1095,8 +1225,8 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
DIR_TESTDATA . '/images/test-image-mime-jpg.png',
|
||||
'test-image-mime-jpg.png',
|
||||
array(
|
||||
'ext' => 'jpg',
|
||||
'type' => 'image/jpeg',
|
||||
'ext' => 'jpg',
|
||||
'type' => 'image/jpeg',
|
||||
'proper_filename' => 'test-image-mime-jpg.jpg',
|
||||
),
|
||||
),
|
||||
@@ -1105,8 +1235,8 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
DIR_TESTDATA . '/images/test-image-no-extension',
|
||||
'test-image-no-extension',
|
||||
array(
|
||||
'ext' => false,
|
||||
'type' => false,
|
||||
'ext' => false,
|
||||
'type' => false,
|
||||
'proper_filename' => false,
|
||||
),
|
||||
),
|
||||
@@ -1115,8 +1245,8 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
DIR_TESTDATA . '/formatting/big5.txt',
|
||||
'big5.jpg',
|
||||
array(
|
||||
'ext' => 'jpg',
|
||||
'type' => 'image/jpeg',
|
||||
'ext' => 'jpg',
|
||||
'type' => 'image/jpeg',
|
||||
'proper_filename' => false,
|
||||
),
|
||||
),
|
||||
@@ -1125,8 +1255,8 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
DIR_TESTDATA . '/export/crazy-cdata.xml',
|
||||
'crazy-cdata.xml',
|
||||
array(
|
||||
'ext' => false,
|
||||
'type' => false,
|
||||
'ext' => false,
|
||||
'type' => false,
|
||||
'proper_filename' => false,
|
||||
),
|
||||
),
|
||||
@@ -1134,28 +1264,30 @@ class Tests_Functions extends WP_UnitTestCase {
|
||||
|
||||
// Test a few additional file types on single sites.
|
||||
if ( ! is_multisite() ) {
|
||||
$data = array_merge( $data, array(
|
||||
// Standard non-image file.
|
||||
array(
|
||||
DIR_TESTDATA . '/formatting/big5.txt',
|
||||
'big5.txt',
|
||||
$data = array_merge(
|
||||
$data, array(
|
||||
// Standard non-image file.
|
||||
array(
|
||||
DIR_TESTDATA . '/formatting/big5.txt',
|
||||
'big5.txt',
|
||||
array(
|
||||
'ext' => 'txt',
|
||||
'type' => 'text/plain',
|
||||
'proper_filename' => false,
|
||||
),
|
||||
),
|
||||
// Non-image file with wrong sub-type.
|
||||
array(
|
||||
'ext' => 'txt',
|
||||
'type' => 'text/plain',
|
||||
'proper_filename' => false,
|
||||
DIR_TESTDATA . '/uploads/pages-to-word.docx',
|
||||
'pages-to-word.docx',
|
||||
array(
|
||||
'ext' => 'docx',
|
||||
'type' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'proper_filename' => false,
|
||||
),
|
||||
),
|
||||
),
|
||||
// Non-image file with wrong sub-type.
|
||||
array(
|
||||
DIR_TESTDATA . '/uploads/pages-to-word.docx',
|
||||
'pages-to-word.docx',
|
||||
array(
|
||||
'ext' => 'docx',
|
||||
'type' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'proper_filename' => false,
|
||||
),
|
||||
),
|
||||
) );
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
Reference in New Issue
Block a user