From 12156f6fab379dcfe816441e1d9545266475e1ba Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 31 Jan 2015 02:01:46 +0000 Subject: [PATCH] Add a unit test that expects wp_parse_args() to treat `'true'` and `'false'` in a query string as strings. props voldemortensen for initial patch. see #30753. git-svn-id: https://develop.svn.wordpress.org/trunk@31310 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/functions.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index 61f9c243a6..d4f9e40da2 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -13,6 +13,7 @@ class Tests_Functions extends WP_UnitTestCase { $y = new MockClass; $this->assertEquals(array(), wp_parse_args($y)); } + function test_wp_parse_args_array() { // arrays $a = array(); @@ -20,6 +21,7 @@ class Tests_Functions extends WP_UnitTestCase { $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->_baba = 5; @@ -30,6 +32,7 @@ class Tests_Functions extends WP_UnitTestCase { $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); @@ -38,6 +41,16 @@ class Tests_Functions extends WP_UnitTestCase { wp_parse_str($q, $ss); $this->assertEquals($ss, wp_parse_args($q)); } + + /** + * @ticket 30753 + */ + function test_wp_parse_args_boolean_strings() { + $args = wp_parse_args( 'foo=false&bar=true', array() ); + $this->assertInternalType( 'string', $args['foo'] ); + $this->assertInternalType( 'string', $args['bar'] ); + } + function test_size_format() { $b = 1; $kb = 1024;