From 9768cbf1b1ae369335e0675f0af78e3e5f03d7ec Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 21 Jan 2011 16:40:41 -0700 Subject: [PATCH] Convert horde/Serialize to PHPUnit --- framework/Serialize/package.xml | 85 ++- .../Serialize/test/Horde/Serialize/AllTests.php | 38 ++ .../Serialize/test/Horde/Serialize/Autoload.php | 28 + .../Serialize/test/Horde/Serialize/JsonTest.php | 631 +++++++++++++++++++++ .../test/Horde/Serialize/json_assoc_array.phpt | 52 -- .../Serialize/test/Horde/Serialize/json_empty.phpt | 42 -- .../test/Horde/Serialize/json_encode_badutf8.phpt | 22 - .../test/Horde/Serialize/json_encode_decode.phpt | 302 ---------- .../test/Horde/Serialize/json_nested_array.phpt | 115 ---- .../test/Horde/Serialize/json_object.phpt | 41 -- .../test/Horde/Serialize/json_spaces_comments.phpt | 145 ----- .../test/Horde/Serialize/json_unquoted_keys.phpt | 60 -- 12 files changed, 754 insertions(+), 807 deletions(-) create mode 100644 framework/Serialize/test/Horde/Serialize/AllTests.php create mode 100644 framework/Serialize/test/Horde/Serialize/Autoload.php create mode 100644 framework/Serialize/test/Horde/Serialize/JsonTest.php delete mode 100644 framework/Serialize/test/Horde/Serialize/json_assoc_array.phpt delete mode 100644 framework/Serialize/test/Horde/Serialize/json_empty.phpt delete mode 100644 framework/Serialize/test/Horde/Serialize/json_encode_badutf8.phpt delete mode 100644 framework/Serialize/test/Horde/Serialize/json_encode_decode.phpt delete mode 100644 framework/Serialize/test/Horde/Serialize/json_nested_array.phpt delete mode 100644 framework/Serialize/test/Horde/Serialize/json_object.phpt delete mode 100644 framework/Serialize/test/Horde/Serialize/json_spaces_comments.phpt delete mode 100644 framework/Serialize/test/Horde/Serialize/json_unquoted_keys.phpt diff --git a/framework/Serialize/package.xml b/framework/Serialize/package.xml index 421233a3b..8bd6605f0 100644 --- a/framework/Serialize/package.xml +++ b/framework/Serialize/package.xml @@ -1,14 +1,10 @@ - + Serialize pear.horde.org Data Encapulation API The Horde_Serialize:: class provides various methods of - encapsulating data. - + encapsulating data. Chuck Hagenbuch chuck @@ -21,7 +17,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> jan@horde.org yes - 2009-02-12 + 2011-01-21 + 0.1.0 0.1.0 @@ -31,12 +28,23 @@ http://pear.php.net/dtd/package-2.0.xsd"> beta LGPL - * Throw exceptions rather than returning PEAR_Errors. + +* Throw exceptions rather than returning PEAR_Errors. * Add support for limited error handling for json encoding errors (requires PHP 5.3+). - * Initial Horde 4 package. + * Initial Horde 4 package. + - + + + + + + + + + + @@ -44,21 +52,16 @@ http://pear.php.net/dtd/package-2.0.xsd"> - + - - - - - - - - + + + @@ -110,12 +113,32 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - + + + + + + + + + 0.0.1 + 0.0.1 + + + alpha + alpha + + 2004-01-01 + LGPL + +Initial packaging. + + + 2006-05-08 @@ -127,20 +150,26 @@ http://pear.php.net/dtd/package-2.0.xsd"> alpha LGPL - Converted to package.xml 2.0 for pear.horde.org + +Converted to package.xml 2.0 for pear.horde.org + - 0.0.1 - 0.0.1 + 0.1.0 + 0.1.0 - alpha - alpha + beta + beta - 2004-01-01 + 2011-01-21 LGPL - Initial packaging. + +* Throw exceptions rather than returning PEAR_Errors. + * Add support for limited error handling for json encoding errors + (requires PHP 5.3+). + * Initial Horde 4 package. diff --git a/framework/Serialize/test/Horde/Serialize/AllTests.php b/framework/Serialize/test/Horde/Serialize/AllTests.php new file mode 100644 index 000000000..098e8144c --- /dev/null +++ b/framework/Serialize/test/Horde/Serialize/AllTests.php @@ -0,0 +1,38 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Serialize + * @package Serialize + * @subpackage UnitTests + */ + +/** + * Define the main method + */ +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'Horde_Serialize_AllTests::main'); +} + +/** + * Prepare the test setup. + */ +require_once 'Horde/Test/AllTests.php'; + +/** + * @category Horde + * @package Serialize + * @subpackage UnitTests + */ +class Horde_Serialize_AllTests extends Horde_Test_AllTests +{ +} + +Horde_Serialize_AllTests::init('Horde_Serialize', __FILE__); + +if (PHPUnit_MAIN_METHOD == 'Horde_Serialize_AllTests::main') { + Horde_Serialize_AllTests::main(); +} diff --git a/framework/Serialize/test/Horde/Serialize/Autoload.php b/framework/Serialize/test/Horde/Serialize/Autoload.php new file mode 100644 index 000000000..4d3cfd275 --- /dev/null +++ b/framework/Serialize/test/Horde/Serialize/Autoload.php @@ -0,0 +1,28 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Serialize + */ + +if (!spl_autoload_functions()) { + spl_autoload_register( + create_function( + '$class', + '$filename = str_replace(array(\'::\', \'_\'), \'/\', $class);' + . '$err_mask = E_ALL ^ E_WARNING;' + . '$oldErrorReporting = error_reporting($err_mask);' + . 'include "$filename.php";' + . 'error_reporting($oldErrorReporting);' + ) + ); +} + +/** Catch strict standards */ +error_reporting(E_ALL | E_STRICT); diff --git a/framework/Serialize/test/Horde/Serialize/JsonTest.php b/framework/Serialize/test/Horde/Serialize/JsonTest.php new file mode 100644 index 000000000..51356dc1e --- /dev/null +++ b/framework/Serialize/test/Horde/Serialize/JsonTest.php @@ -0,0 +1,631 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Serialize + * @subpackage UnitTests + */ + +class Horde_Serialize_JsonTest extends PHPUnit_Framework_TestCase +{ + // JSON associative arrays tests. + public function testJsonAssociativeArray() + { + // array case - strict: associative array with nested associative + // arrays + $arr = array( + 'car1'=> array( + 'color'=> 'tan', + 'model' => 'sedan' + ), + 'car2' => array( + 'color' => 'red', + 'model' => 'sports' + ) + ); + + $this->assertEquals( + '{"car1":{"color":"tan","model":"sedan"},"car2":{"color":"red","model":"sports"}}', + Horde_Serialize::serialize($arr, Horde_Serialize::JSON) + ); + + // array case - strict: associative array with nested associative + // arrays, and some numeric keys thrown in + // Should degrade to a numeric array. + $arn = array( + 0 => array( + 0 => 'tan\\', + 'model\\' => 'sedan' + ), + 1 => array( + 0 => 'red', + 'model' => 'sports' + ) + ); + $arn_ja = '[{"0":"tan\\\\","model\\\\":"sedan"},{"0":"red","model":"sports"}]'; + $this->assertEquals( + $arn_ja, + Horde_Serialize::serialize($arn, Horde_Serialize::JSON) + ); + + $this->assertInternalType( + 'array', + Horde_Serialize::unserialize($arn_ja, Horde_Serialize::JSON) + ); + + // sparse numeric assoc array: associative array numeric keys which + // are not fully populated in a range of 0 to length-1 + // Test a sparsely populated numerically indexed associative array. + $arrs = array( + 1 => 'one', + 2 => 'two', + 5 => 'five' + ); + $this->assertEquals( + '{"1":"one","2":"two","5":"five"}', + Horde_Serialize::serialize($arrs, Horde_Serialize::JSON) + ); + } + + // JSON empties tests. + public function testJsonEmpties() + { + $obj0_j = '{}'; + $obj1_j = '{ }'; + + $this->assertInternalType( + 'object', + Horde_Serialize::unserialize($obj0_j, Horde_Serialize::JSON) + ); + $this->assertEquals( + '0', + count(get_object_vars(Horde_Serialize::unserialize($obj0_j, Horde_Serialize::JSON))) + ); + + $this->assertInternalType( + 'object', + Horde_Serialize::unserialize($obj1_j, Horde_Serialize::JSON) + ); + $this->assertEquals( + '0', + count(get_object_vars(Horde_Serialize::unserialize($obj1_j, Horde_Serialize::JSON))) + ); + } + + // JSON encode/decode tests (invalid UTF-8 input). + public function testJsonInvalidUTF8Input() + { + if (version_compare(phpversion(), '5.3.0') == -1) { + $this->markTestSkipped("skip Test requires PHP 5.3+"); + } + + $this->assertEquals( + '"Note: To play video messages sent to email, QuickTime\u00ae 6.5 or higher is required.\n"', + Horde_Serialize::serialize(file_get_contents('./fixtures/badutf8.txt'), Horde_Serialize::JSON) + ); + } + + // JSON encode/decode tests. + public function testJsonEncodeAndDecode() + { + $obj = new stdClass(); + $obj->a_string = '"he":llo}:{world'; + $obj->an_array = array(1, 2, 3); + $obj->obj = new stdClass(); + $obj->obj->a_number = 123; + $obj_j = '{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"obj":{"a_number":123}}'; + + $arr = array(null, true, array(1, 2, 3), "hello\"],[world!"); + $arr_j = '[null,true,[1,2,3],"hello\"],[world!"]'; + + $str1 = 'hello world'; + $str1_j = '"hello world"'; + $str1_j_ = "'hello world'"; + + $str2 = "hello\t\"world\""; + $str2_j = '"hello\\t\\"world\\""'; + + $str3 = "\\\r\n\t\"/"; + $str3_j = '"\\\\\\r\\n\\t\\"\\/"'; + + $str4 = 'héllö wørłd'; + $str4_j = '"h\u00e9ll\u00f6 w\u00f8r\u0142d"'; + $str4_j_ = '"héllö wørłd"'; + + // type case: null + $this->assertEquals( + 'null', + Horde_Serialize::serialize(null, Horde_Serialize::JSON) + ); + + // type case: boolean true + $this->assertEquals( + 'true', + Horde_Serialize::serialize(true, Horde_Serialize::JSON) + ); + + // type case: boolean false + $this->assertEquals( + 'false', + Horde_Serialize::serialize(false, Horde_Serialize::JSON) + ); + + // numeric case: 1 + $this->assertEquals( + 1, + Horde_Serialize::serialize(1, Horde_Serialize::JSON) + ); + + // numeric case: -1 + $this->assertEquals( + -1, + Horde_Serialize::serialize(-1, Horde_Serialize::JSON) + ); + + // numeric case: 1.0 + $this->assertEquals( + 1, + Horde_Serialize::serialize(1.0, Horde_Serialize::JSON) + ); + + // numeric case: 1.1 + $this->assertEquals( + 1.1, + Horde_Serialize::serialize(1.1, Horde_Serialize::JSON) + ); + + // string case: hello world + $this->assertEquals( + $str1_j, + Horde_Serialize::serialize($str1, Horde_Serialize::JSON) + ); + + // string case: hello world, with tab, double-quotes + $this->assertEquals( + $str2_j, + Horde_Serialize::serialize($str2, Horde_Serialize::JSON) + ); + + // string case: backslash, return, newline, tab, double-quote + $this->assertEquals( + $str3_j, + Horde_Serialize::serialize($str3, Horde_Serialize::JSON) + ); + + // string case: hello world, with unicode + $this->assertEquals( + $str4_j, + Horde_Serialize::serialize($str4, Horde_Serialize::JSON) + ); + + // array case: array with elements and nested arrays + $this->assertEquals( + '[null,true,[1,2,3],"hello\"],[world!"]', + Horde_Serialize::serialize($arr, Horde_Serialize::JSON) + ); + + // object case: object with properties, nested object and arrays + $this->assertEquals( + '{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"obj":{"a_number":123}}', + Horde_Serialize::serialize($obj, Horde_Serialize::JSON) + ); + + // type case: null + $this->assertNull( + Horde_Serialize::unserialize('null', Horde_Serialize::JSON) + ); + + // type case: boolean true + $this->assertTrue( + Horde_Serialize::unserialize('true', Horde_Serialize::JSON) + ); + + // type case: boolean false + $this->assertFalse( + Horde_Serialize::unserialize('false', Horde_Serialize::JSON) + ); + + // numeric case: 1 + $this->assertEquals( + 1, + Horde_Serialize::unserialize('1', Horde_Serialize::JSON) + ); + + // numeric case: -1 + $this->assertEquals( + -1, + Horde_Serialize::unserialize('-1', Horde_Serialize::JSON) + ); + + // numeric case: 1.0 + $this->assertEquals( + 1.0, + Horde_Serialize::unserialize('1.0', Horde_Serialize::JSON) + ); + $this->assertInternalType( + 'float', + Horde_Serialize::unserialize('1.0', Horde_Serialize::JSON) + ); + + // numeric case: 1.1 + $this->assertEquals( + 1.1, + Horde_Serialize::unserialize('1.1', Horde_Serialize::JSON) + ); + $this->assertInternalType( + 'float', + Horde_Serialize::unserialize('1.1', Horde_Serialize::JSON) + ); + + + // string case: hello world + $this->assertEquals( + $str1, + Horde_Serialize::unserialize($str1_j, Horde_Serialize::JSON) + ); + $this->assertEquals( + "'" . $str1 . "'", + Horde_Serialize::unserialize($str1_j_, Horde_Serialize::JSON) + ); + + // string case: hello world, with tab, double-quotes + $this->assertEquals( + $str2, + Horde_Serialize::unserialize($str2_j, Horde_Serialize::JSON) + ); + + // string case: backslash, return, newline, tab, double-quote + $this->assertEquals( + $str3, + Horde_Serialize::unserialize($str3_j, Horde_Serialize::JSON) + ); + + // string case: hello world, with unicode + $this->assertEquals( + $str4, + Horde_Serialize::unserialize($str4_j, Horde_Serialize::JSON) + ); + $this->assertEquals( + $str4, + Horde_Serialize::unserialize($str4_j_, Horde_Serialize::JSON) + ); + + // array case: array with elements and nested arrays + $this->assertEquals( + $arr, + Horde_Serialize::unserialize($arr_j, Horde_Serialize::JSON) + ); + + // object case: object with properties, nested object and arrays + $this->assertEquals( + $obj, + Horde_Serialize::unserialize($obj_j, Horde_Serialize::JSON) + ); + + // type case: null + $this->assertNull( + Horde_Serialize::unserialize(Horde_Serialize::serialize(null, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // type case: boolean true + $this->assertTrue( + Horde_Serialize::unserialize(Horde_Serialize::serialize(true, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // type case: boolean false + $this->assertFalse( + Horde_Serialize::unserialize(Horde_Serialize::serialize(false, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // numeric case: 1 + $this->assertEquals( + 1, + Horde_Serialize::unserialize(Horde_Serialize::serialize(1, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // numeric case: -1 + $this->assertEquals( + -1, + Horde_Serialize::unserialize(Horde_Serialize::serialize(-1, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // numeric case: 1.0 + $this->assertEquals( + 1, + Horde_Serialize::unserialize(Horde_Serialize::serialize(1.0, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // numeric case: 1.1 + $this->assertEquals( + 1.1, + Horde_Serialize::unserialize(Horde_Serialize::serialize(1.1, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // string case: hello world + $this->assertEquals( + $str1, + Horde_Serialize::unserialize(Horde_Serialize::serialize($str1, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // string case: hello world, with tab, double-quotes + $this->assertEquals( + $str2, + Horde_Serialize::unserialize(Horde_Serialize::serialize($str2, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // string case: backslash, return, newline, tab, double-quote + $this->assertEquals( + $str3, + Horde_Serialize::unserialize(Horde_Serialize::serialize($str3, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // string case: hello world, with unicode + $this->assertEquals( + $str4, + Horde_Serialize::unserialize(Horde_Serialize::serialize($str4, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // array case: array with elements and nested arrays + $this->assertEquals( + $arr, + Horde_Serialize::unserialize(Horde_Serialize::serialize($arr, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // object case: object with properties, nested object and arrays + $this->assertEquals( + $obj, + Horde_Serialize::unserialize(Horde_Serialize::serialize($obj, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // type case: null + $this->assertEquals( + 'null', + Horde_Serialize::serialize(Horde_Serialize::unserialize('null', Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // type case: boolean true + $this->assertEquals( + 'true', + Horde_Serialize::serialize(Horde_Serialize::unserialize('true', Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // type case: boolean false + $this->assertEquals( + 'false', + Horde_Serialize::serialize(Horde_Serialize::unserialize('false', Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // numeric case: 1 + $this->assertEquals( + '1', + Horde_Serialize::serialize(Horde_Serialize::unserialize('1', Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // numeric case: -1 + $this->assertEquals( + '-1', + Horde_Serialize::serialize(Horde_Serialize::unserialize('-1', Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // numeric case: 1.0 + $this->assertEquals( + '1.0', + Horde_Serialize::serialize(Horde_Serialize::unserialize('1.0', Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // numeric case: 1.1 + $this->assertEquals( + '1.1', + Horde_Serialize::serialize(Horde_Serialize::unserialize('1.1', Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // string case: hello world + $this->assertEquals( + $str1_j, + Horde_Serialize::serialize(Horde_Serialize::unserialize($str1_j, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // string case: hello world, with tab, double-quotes + $this->assertEquals( + $str2_j, + Horde_Serialize::serialize(Horde_Serialize::unserialize($str2_j, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // string case: backslash, return, newline, tab, double-quote + $this->assertEquals( + $str3_j, + Horde_Serialize::serialize(Horde_Serialize::unserialize($str3_j, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // string case: hello world, with unicode + $this->assertEquals( + $str4_j, + Horde_Serialize::serialize(Horde_Serialize::unserialize($str4_j, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + $this->assertEquals( + $str4_j, + Horde_Serialize::serialize(Horde_Serialize::unserialize($str4_j_, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // array case: array with elements and nested arrays + $this->assertEquals( + $arr_j, + Horde_Serialize::serialize(Horde_Serialize::unserialize($arr_j, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + + // object case: object with properties, nested object and arrays + $this->assertEquals( + $obj_j, + Horde_Serialize::serialize(Horde_Serialize::unserialize($obj_j, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + } + + // JSON nested arrays tests. + public function testJsonNestedArrays() + { + $str1 = '[{"this":"that"}]'; + $str1_ob = new stdClass; + $str1_ob->this = 'that'; + + $str2 = '{"this":["that"]}'; + $str2_ob = new stdClass; + $str2_ob->this = array('that'); + + $str3 = '{"params":[{"foo":["1"],"bar":"1"}]}'; + $str3_ob = new stdClass; + $str3_ob2 = new stdClass; + $str3_ob2->foo = array(1); + $str3_ob2->bar = 1; + $str3_ob->params = array($str3_ob2); + + $str4 = '[{"foo": "bar", "baz": "winkle"}]'; + $str4_ob2 = new stdClass; + $str4_ob2->foo = 'bar'; + $str4_ob2->baz = 'winkle'; + $str4_ob = array($str4_ob2); + + $str5 = '{"params":[{"options": {"old": [ ], "new": [{"elements": {"old": [], "new": [{"elementName": "aa", "isDefault": false, "elementRank": "0", "priceAdjust": "0", "partNumber": ""}]}}], "optionName": "aa", "isRequired": false, "optionDesc": ""}}]}'; + + $str5_ob = new stdClass; + $str5_ob->params = array(new stdClass); + $str5_ob->params[0]->options = new stdClass; + $str5_ob->params[0]->options->old = array(); + $str5_ob->params[0]->options->new = array(new stdClass); + $str5_ob->params[0]->options->new[0]->elements = new stdClass; + $str5_ob->params[0]->options->new[0]->elements->old = array(); + $str5_ob->params[0]->options->new[0]->elements->new = array(new stdClass); + $str5_ob->params[0]->options->new[0]->elements->new[0]->elementName = 'aa'; + $str5_ob->params[0]->options->new[0]->elements->new[0]->isDefault = false; + $str5_ob->params[0]->options->new[0]->elements->new[0]->elementRank = 0; + $str5_ob->params[0]->options->new[0]->elements->new[0]->priceAdjust = 0; + $str5_ob->params[0]->options->new[0]->elements->new[0]->partNumber = ''; + $str5_ob->params[0]->options->optionName = 'aa'; + $str5_ob->params[0]->options->isRequired = false; + $str5_ob->params[0]->options->optionDesc = ''; + + // simple compactly-nested array + $this->assertEquals( + array($str1_ob), + Horde_Serialize::unserialize($str1, Horde_Serialize::JSON) + ); + + // simple compactly-nested array + $this->assertEquals( + $str2_ob, + Horde_Serialize::unserialize($str2, Horde_Serialize::JSON) + ); + + // complex compactly nested array + $this->assertEquals( + $str3_ob, + Horde_Serialize::unserialize($str3, Horde_Serialize::JSON) + ); + + // complex compactly nested array + $this->assertEquals( + $str4_ob, + Horde_Serialize::unserialize($str4, Horde_Serialize::JSON) + ); + + // super complex compactly nested array + $this->assertEquals( + $str5_ob, + Horde_Serialize::unserialize($str5, Horde_Serialize::JSON) + ); + } + + // JSON objects tests. + public function testJsonObjects() + { + $obj_j = '{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"obj":{"a_number":123}}'; + + $obj1 = new stdClass; + $obj1->car1 = new stdClass; + $obj1->car1->color = 'tan'; + $obj1->car1->model = 'sedan'; + $obj1->car2 = new stdClass; + $obj1->car2->color = 'red'; + $obj1->car2->model = 'sports'; + $obj1_j = '{"car1":{"color":"tan","model":"sedan"},"car2":{"color":"red","model":"sports"}}'; + + $this->assertInternalType( + 'object', + Horde_Serialize::unserialize($obj_j, Horde_Serialize::JSON) + ); + + // object - strict: Object with nested objects + $this->assertEquals( + $obj1_j, + Horde_Serialize::serialize($obj1, Horde_Serialize::JSON) + ); + + // object case + $this->assertEquals( + $obj_j, + Horde_Serialize::serialize(Horde_Serialize::unserialize($obj_j, Horde_Serialize::JSON), Horde_Serialize::JSON) + ); + } + + // JSON spaces tests. + public function testJsonSpaces() + { + $obj = new stdClass; + $obj->a_string = "\"he\":llo}:{world"; + $obj->an_array = array(1, 2, 3); + $obj->obj = new stdClass; + $obj->obj->a_number = 123; + + $obj_js = '{"a_string": "\"he\":llo}:{world", + "an_array":[1, 2, 3], + "obj": {"a_number":123}}'; + + // checking whether notation with spaces works + $this->assertEquals( + $obj, + Horde_Serialize::unserialize($obj_js, Horde_Serialize::JSON) + ); + } + + // JSON unquoted keys tests. + public function testJsonUnquotedKeys() + { + $ob1 = new stdClass; + $ob1->{'0'} = 'tan'; + $ob1->model = 'sedan'; + + $ob2 = new stdClass; + $ob2->{'0'} = 'red'; + $ob2->model = 'sports'; + + $arn = array($ob1, $ob2); + $arn_ja = '[{"0":"tan","model":"sedan"},{"0":"red","model":"sports"}]'; + + $arrs = new stdClass; + $arrs->{'1'} = 'one'; + $arrs->{'2'} = 'two'; + $arrs->{'5'} = 'fi"ve'; + $arrs_jo = '{"1":"one","2":"two","5":"fi\"ve"}'; + + // array case - strict: associative array with unquoted keys, nested + // associative arrays, and some numeric keys thrown in + // ...unless the input array has some numeric indices, in which case + // the behavior is to degrade to a regular array + $this->assertEquals( + $arn_ja, + Horde_Serialize::serialize($arn, Horde_Serialize::JSON) + ); + + // sparse numeric assoc array: associative array with unquoted keys, + // single-quoted values, numeric keys which are not fully populated in + // a range of 0 to length-1 + // Test a sparsely populated numerically indexed associative array + $this->assertEquals( + $arrs_jo, + Horde_Serialize::serialize($arrs, Horde_Serialize::JSON) + ); + } + +} diff --git a/framework/Serialize/test/Horde/Serialize/json_assoc_array.phpt b/framework/Serialize/test/Horde/Serialize/json_assoc_array.phpt deleted file mode 100644 index 7d8ff3ab4..000000000 --- a/framework/Serialize/test/Horde/Serialize/json_assoc_array.phpt +++ /dev/null @@ -1,52 +0,0 @@ ---TEST-- -JSON associative arrays tests. ---FILE-- - array('color'=> 'tan', 'model' => 'sedan'), - 'car2' => array('color' => 'red', 'model' => 'sports')); -$arr_jo = '{"car1":{"color":"tan","model":"sedan"},"car2":{"color":"red","model":"sports"}}'; - -$arn = array(0 => array(0 => 'tan\\', 'model\\' => 'sedan'), 1 => array(0 => 'red', 'model' => 'sports')); -$arn_ja = '[{"0":"tan\\\\","model\\\\":"sedan"},{"0":"red","model":"sports"}]'; - -$arrs = array(1 => 'one', 2 => 'two', 5 => 'five'); -$arrs_jo = '{"1":"one","2":"two","5":"five"}'; - -/* Types test */ - -// strict type should be array -out(gettype(Horde_Serialize::unserialize($arn_ja, Horde_Serialize::JSON))); - -echo"============================================================================\n"; - -/* Encode tests */ - -// array case - strict: associative array with nested associative arrays -out(Horde_Serialize::serialize($arr, Horde_Serialize::JSON)); - -// array case - strict: associative array with nested associative arrays, and -// some numeric keys thrown in -// Should degrade to a numeric array. -out(Horde_Serialize::serialize($arn, Horde_Serialize::JSON)); - -// sparse numeric assoc array: associative array numeric keys which are not -// fully populated in a range of 0 to length-1 -// Test a sparsely populated numerically indexed associative array. -out(Horde_Serialize::serialize($arrs, Horde_Serialize::JSON)); - -?> ---EXPECT-- -array -============================================================================ -{"car1":{"color":"tan","model":"sedan"},"car2":{"color":"red","model":"sports"}} -[{"0":"tan\\","model\\":"sedan"},{"0":"red","model":"sports"}] -{"1":"one","2":"two","5":"five"} diff --git a/framework/Serialize/test/Horde/Serialize/json_empty.phpt b/framework/Serialize/test/Horde/Serialize/json_empty.phpt deleted file mode 100644 index f370e0633..000000000 --- a/framework/Serialize/test/Horde/Serialize/json_empty.phpt +++ /dev/null @@ -1,42 +0,0 @@ ---TEST-- -JSON empties tests. ---FILE-- - ---EXPECT-- -object -0 -object -0 -object -0 diff --git a/framework/Serialize/test/Horde/Serialize/json_encode_badutf8.phpt b/framework/Serialize/test/Horde/Serialize/json_encode_badutf8.phpt deleted file mode 100644 index 0ed4810e5..000000000 --- a/framework/Serialize/test/Horde/Serialize/json_encode_badutf8.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -JSON encode/decode tests (invalid UTF-8 input). ---SKIPIF-- - ---FILE-- - ---EXPECT-- -"Note: To play video messages sent to email, QuickTime\u00ae 6.5 or higher is required.\n" diff --git a/framework/Serialize/test/Horde/Serialize/json_encode_decode.phpt b/framework/Serialize/test/Horde/Serialize/json_encode_decode.phpt deleted file mode 100644 index 71ee6cb08..000000000 --- a/framework/Serialize/test/Horde/Serialize/json_encode_decode.phpt +++ /dev/null @@ -1,302 +0,0 @@ ---TEST-- -JSON encode/decode tests. ---FILE-- -a_string = '"he":llo}:{world'; -$obj->an_array = array(1, 2, 3); -$obj->obj = new stdClass(); -$obj->obj->a_number = 123; -$obj_j = '{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"obj":{"a_number":123}}'; - -$arr = array(null, true, array(1, 2, 3), "hello\"],[world!"); -$arr_j = '[null,true,[1,2,3],"hello\"],[world!"]'; - -$str1 = 'hello world'; -$str1_j = '"hello world"'; -$str1_j_ = "'hello world'"; - -$str2 = "hello\t\"world\""; -$str2_j = '"hello\\t\\"world\\""'; - -$str3 = "\\\r\n\t\"/"; -$str3_j = '"\\\\\\r\\n\\t\\"\\/"'; - -$str4 = 'héllö wørłd'; -$str4_j = '"h\u00e9ll\u00f6 w\u00f8r\u0142d"'; -$str4_j_ = '"héllö wørłd"'; - -/* Encode tests. */ - -// type case: null -out(Horde_Serialize::serialize(null, Horde_Serialize::JSON)); -// type case: boolean true -out(Horde_Serialize::serialize(true, Horde_Serialize::JSON)); -// type case: boolean false -out(Horde_Serialize::serialize(false, Horde_Serialize::JSON)); - -// numeric case: 1 -out(Horde_Serialize::serialize(1, Horde_Serialize::JSON)); -// numeric case: -1 -out(Horde_Serialize::serialize(-1, Horde_Serialize::JSON)); -// numeric case: 1.0 -out(Horde_Serialize::serialize(1.0, Horde_Serialize::JSON)); -// numeric case: 1.1 -out(Horde_Serialize::serialize(1.1, Horde_Serialize::JSON)); - -// string case: hello world -out(Horde_Serialize::serialize($str1, Horde_Serialize::JSON)); -// string case: hello world, with tab, double-quotes -out(Horde_Serialize::serialize($str2, Horde_Serialize::JSON)); -// string case: backslash, return, newline, tab, double-quote -out(Horde_Serialize::serialize($str3, Horde_Serialize::JSON)); -// string case: hello world, with unicode -out(Horde_Serialize::serialize($str4, Horde_Serialize::JSON)); - -// array case: array with elements and nested arrays -out(Horde_Serialize::serialize($arr, Horde_Serialize::JSON)); -// object case: object with properties, nested object and arrays -out(Horde_Serialize::serialize($obj, Horde_Serialize::JSON)); - -echo"============================================================================\n"; - -/* Decode tests */ - -// type case: null -var_dump(Horde_Serialize::unserialize('null', Horde_Serialize::JSON)); -// type case: boolean true -var_dump(Horde_Serialize::unserialize('true', Horde_Serialize::JSON)); -// type case: boolean false -var_dump(Horde_Serialize::unserialize('false', Horde_Serialize::JSON)); - -// numeric case: 1 -var_dump(Horde_Serialize::unserialize('1', Horde_Serialize::JSON)); -// numeric case: -1 -var_dump(Horde_Serialize::unserialize('-1', Horde_Serialize::JSON)); -// numeric case: 1.0 -var_dump(Horde_Serialize::unserialize('1.0', Horde_Serialize::JSON)); -// numeric case: 1.1 -var_dump(Horde_Serialize::unserialize('1.1', Horde_Serialize::JSON)); - -// string case: hello world -var_dump(Horde_Serialize::unserialize($str1_j, Horde_Serialize::JSON)); -var_dump(Horde_Serialize::unserialize($str1_j_, Horde_Serialize::JSON)); -// string case: hello world, with tab, double-quotes -var_dump(Horde_Serialize::unserialize($str2_j, Horde_Serialize::JSON)); -// string case: backslash, return, newline, tab, double-quote -var_dump(Horde_Serialize::unserialize($str3_j, Horde_Serialize::JSON)); -// string case: hello world, with unicode -var_dump(Horde_Serialize::unserialize($str4_j, Horde_Serialize::JSON)); -var_dump(Horde_Serialize::unserialize($str4_j_, Horde_Serialize::JSON)); - -// array case: array with elements and nested arrays -var_dump(Horde_Serialize::unserialize($arr_j, Horde_Serialize::JSON)); -// object case: object with properties, nested object and arrays -var_dump(Horde_Serialize::unserialize($obj_j, Horde_Serialize::JSON)); - -echo"============================================================================\n"; - -/* Encode-decode tests */ - -// type case: null -var_dump(Horde_Serialize::unserialize(Horde_Serialize::serialize(null, Horde_Serialize::JSON), Horde_Serialize::JSON)); -// type case: boolean true -var_dump(Horde_Serialize::unserialize(Horde_Serialize::serialize(true, Horde_Serialize::JSON), Horde_Serialize::JSON)); -// type case: boolean false -var_dump(Horde_Serialize::unserialize(Horde_Serialize::serialize(false, Horde_Serialize::JSON), Horde_Serialize::JSON)); - -// numeric case: 1 -var_dump(Horde_Serialize::unserialize(Horde_Serialize::serialize(1, Horde_Serialize::JSON), Horde_Serialize::JSON)); -// numeric case: -1 -var_dump(Horde_Serialize::unserialize(Horde_Serialize::serialize(-1, Horde_Serialize::JSON), Horde_Serialize::JSON)); -// numeric case: 1.0 -var_dump(Horde_Serialize::unserialize(Horde_Serialize::serialize(1.0, Horde_Serialize::JSON), Horde_Serialize::JSON)); -// numeric case: 1.1 -var_dump(Horde_Serialize::unserialize(Horde_Serialize::serialize(1.1, Horde_Serialize::JSON), Horde_Serialize::JSON)); - -// string case: hello world -var_dump(Horde_Serialize::unserialize(Horde_Serialize::serialize($str1, Horde_Serialize::JSON), Horde_Serialize::JSON)); -// string case: hello world, with tab, double-quotes -var_dump(Horde_Serialize::unserialize(Horde_Serialize::serialize($str2, Horde_Serialize::JSON), Horde_Serialize::JSON)); -// string case: backslash, return, newline, tab, double-quote -var_dump(Horde_Serialize::unserialize(Horde_Serialize::serialize($str3, Horde_Serialize::JSON), Horde_Serialize::JSON)); -// string case: hello world, with unicode -var_dump(Horde_Serialize::unserialize(Horde_Serialize::serialize($str4, Horde_Serialize::JSON), Horde_Serialize::JSON)); - -// array case: array with elements and nested arrays -var_dump(Horde_Serialize::unserialize(Horde_Serialize::serialize($arr, Horde_Serialize::JSON), Horde_Serialize::JSON)); -// object case: object with properties, nested object and arrays -var_dump(Horde_Serialize::unserialize(Horde_Serialize::serialize($obj, Horde_Serialize::JSON), Horde_Serialize::JSON)); - -echo"============================================================================\n"; - -/* Decode-encode tests */ - -// type case: null -out(Horde_Serialize::serialize(Horde_Serialize::unserialize('null', Horde_Serialize::JSON), Horde_Serialize::JSON)); -// type case: boolean true -out(Horde_Serialize::serialize(Horde_Serialize::unserialize('true', Horde_Serialize::JSON), Horde_Serialize::JSON)); -// type case: boolean false -out(Horde_Serialize::serialize(Horde_Serialize::unserialize('false', Horde_Serialize::JSON), Horde_Serialize::JSON)); - -// numeric case: 1 -out(Horde_Serialize::serialize(Horde_Serialize::unserialize('1', Horde_Serialize::JSON), Horde_Serialize::JSON)); -// numeric case: -1 -out(Horde_Serialize::serialize(Horde_Serialize::unserialize('-1', Horde_Serialize::JSON), Horde_Serialize::JSON)); -// numeric case: 1.0 -out(Horde_Serialize::serialize(Horde_Serialize::unserialize('1.0', Horde_Serialize::JSON), Horde_Serialize::JSON)); -// numeric case: 1.1 -out(Horde_Serialize::serialize(Horde_Serialize::unserialize('1.1', Horde_Serialize::JSON), Horde_Serialize::JSON)); - -// string case: hello world -out(Horde_Serialize::serialize(Horde_Serialize::unserialize($str1_j, Horde_Serialize::JSON), Horde_Serialize::JSON)); -// string case: hello world, with tab, double-quotes -out(Horde_Serialize::serialize(Horde_Serialize::unserialize($str2_j, Horde_Serialize::JSON), Horde_Serialize::JSON)); -// string case: backslash, return, newline, tab, double-quote -out(Horde_Serialize::serialize(Horde_Serialize::unserialize($str3_j, Horde_Serialize::JSON), Horde_Serialize::JSON)); -// string case: hello world, with unicode -out(Horde_Serialize::serialize(Horde_Serialize::unserialize($str4_j, Horde_Serialize::JSON), Horde_Serialize::JSON)); -out(Horde_Serialize::serialize(Horde_Serialize::unserialize($str4_j_, Horde_Serialize::JSON), Horde_Serialize::JSON)); - -// array case: array with elements and nested arrays -out(Horde_Serialize::serialize(Horde_Serialize::unserialize($arr_j, Horde_Serialize::JSON), Horde_Serialize::JSON)); -// object case: object with properties, nested object and arrays -out(Horde_Serialize::serialize(Horde_Serialize::unserialize($obj_j, Horde_Serialize::JSON), Horde_Serialize::JSON)); - -?> ---EXPECT-- -null -true -false -1 --1 -1 -1.1 -"hello world" -"hello\t\"world\"" -"\\\r\n\t\"\/" -"h\u00e9ll\u00f6 w\u00f8r\u0142d" -[null,true,[1,2,3],"hello\"],[world!"] -{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"obj":{"a_number":123}} -============================================================================ -NULL -bool(true) -bool(false) -int(1) -int(-1) -float(1) -float(1.1) -string(11) "hello world" -string(11) "hello world" -string(13) "hello "world"" -string(6) "\ - "/" -string(15) "héllö wørłd" -string(15) "héllö wørłd" -array(4) { - [0]=> - NULL - [1]=> - bool(true) - [2]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - [3]=> - string(15) "hello"],[world!" -} -object(stdClass)(3) { - ["a_string"]=> - string(16) ""he":llo}:{world" - ["an_array"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["obj"]=> - object(stdClass)(1) { - ["a_number"]=> - int(123) - } -} -============================================================================ -NULL -bool(true) -bool(false) -int(1) -int(-1) -int(1) -float(1.1) -string(11) "hello world" -string(13) "hello "world"" -string(6) "\ - "/" -string(15) "héllö wørłd" -array(4) { - [0]=> - NULL - [1]=> - bool(true) - [2]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - [3]=> - string(15) "hello"],[world!" -} -object(stdClass)(3) { - ["a_string"]=> - string(16) ""he":llo}:{world" - ["an_array"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["obj"]=> - object(stdClass)(1) { - ["a_number"]=> - int(123) - } -} -============================================================================ -null -true -false -1 --1 -1 -1.1 -"hello world" -"hello\t\"world\"" -"\\\r\n\t\"\/" -"h\u00e9ll\u00f6 w\u00f8r\u0142d" -"h\u00e9ll\u00f6 w\u00f8r\u0142d" -[null,true,[1,2,3],"hello\"],[world!"] -{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"obj":{"a_number":123}} diff --git a/framework/Serialize/test/Horde/Serialize/json_nested_array.phpt b/framework/Serialize/test/Horde/Serialize/json_nested_array.phpt deleted file mode 100644 index da9b66c82..000000000 --- a/framework/Serialize/test/Horde/Serialize/json_nested_array.phpt +++ /dev/null @@ -1,115 +0,0 @@ ---TEST-- -JSON nested arrays tests. ---FILE-- - ---EXPECT-- -array(1) { - [0]=> - object(stdClass)(1) { - ["this"]=> - string(4) "that" - } -} -object(stdClass)(1) { - ["this"]=> - array(1) { - [0]=> - string(4) "that" - } -} -object(stdClass)(1) { - ["params"]=> - array(1) { - [0]=> - object(stdClass)(2) { - ["foo"]=> - array(1) { - [0]=> - string(1) "1" - } - ["bar"]=> - string(1) "1" - } - } -} -object(stdClass)(1) { - [0]=> - object(stdClass)(2) { - ["foo"]=> - string(3) "bar" - ["baz"]=> - string(6) "winkle" - } -} -object(stdClass)(1) { - ["params"]=> - array(1) { - [0]=> - object(stdClass)(1) { - ["options"]=> - object(stdClass)(2) { - ["old"]=> - array(0) { - } - ["new"]=> - object(stdClass)(1) { - [0]=> - object(stdClass)(4) { - ["elements"]=> - object(stdClass)(2) { - ["old"]=> - array(0) { - } - ["new"]=> - object(stdClass)(1) { - [0]=> - object(stdClass)(5) { - ["elementName"]=> - string(2) "aa" - ["isDefault"]=> - bool(false) - ["elementRank"]=> - string(1) "0" - ["priceAdjust"]=> - string(1) "0" - ["partNumber"]=> - string(0) "" - } - } - } - ["optionName"]=> - string(2) "aa" - ["isRequired"]=> - bool(false) - ["optionDesc"]=> - string(0) "" - } - } - } - } - } -} diff --git a/framework/Serialize/test/Horde/Serialize/json_object.phpt b/framework/Serialize/test/Horde/Serialize/json_object.phpt deleted file mode 100644 index e40044782..000000000 --- a/framework/Serialize/test/Horde/Serialize/json_object.phpt +++ /dev/null @@ -1,41 +0,0 @@ ---TEST-- -JSON objects tests. ---FILE-- -car1->color = 'tan'; -$obj1->car1->model = 'sedan'; -$obj1->car2->color = 'red'; -$obj1->car2->model = 'sports'; -$obj1_j = '{"car1":{"color":"tan","model":"sedan"},"car2":{"color":"red","model":"sports"}}'; - -/* Types test */ - -// checking whether decoded type is object -out(gettype(Horde_Serialize::unserialize($obj_j, Horde_Serialize::JSON))); - -/* Encode test */ - -// object - strict: Object with nested objects -out(Horde_Serialize::serialize($obj1, Horde_Serialize::JSON)); - -/* Decode/encode test */ - -// object case -out(Horde_Serialize::serialize(Horde_Serialize::unserialize($obj_j, Horde_Serialize::JSON), Horde_Serialize::JSON)); - -?> ---EXPECT-- -object -{"car1":{"color":"tan","model":"sedan"},"car2":{"color":"red","model":"sports"}} -{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"obj":{"a_number":123}} diff --git a/framework/Serialize/test/Horde/Serialize/json_spaces_comments.phpt b/framework/Serialize/test/Horde/Serialize/json_spaces_comments.phpt deleted file mode 100644 index 033e2ab22..000000000 --- a/framework/Serialize/test/Horde/Serialize/json_spaces_comments.phpt +++ /dev/null @@ -1,145 +0,0 @@ ---TEST-- -JSON spaces and comments tests. ---FILE-- - ---EXPECT-- -object(stdClass)(3) { - ["a_string"]=> - string(16) ""he":llo}:{world" - ["an_array"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["obj"]=> - object(stdClass)(1) { - ["a_number"]=> - int(123) - } -} -object(stdClass)(3) { - ["a_string"]=> - string(16) ""he":llo}:{world" - ["an_array"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["obj"]=> - object(stdClass)(1) { - ["a_number"]=> - int(123) - } -} -object(stdClass)(3) { - ["a_string"]=> - string(16) ""he":llo}:{world" - ["an_array"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["obj"]=> - object(stdClass)(1) { - ["a_number"]=> - int(123) - } -} -string(11) "the sneetch" -object(stdClass)(3) { - ["a_string"]=> - string(16) ""he":llo}:{world" - ["an_array"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["obj"]=> - object(stdClass)(1) { - ["a_number"]=> - int(123) - } -} -object(stdClass)(3) { - ["a_string"]=> - string(16) ""he":llo}:{world" - ["an_array"]=> - array(3) { - [0]=> - int(1) - [1]=> - int(2) - [2]=> - int(3) - } - ["obj"]=> - object(stdClass)(1) { - ["a_number"]=> - int(123) - } -} diff --git a/framework/Serialize/test/Horde/Serialize/json_unquoted_keys.phpt b/framework/Serialize/test/Horde/Serialize/json_unquoted_keys.phpt deleted file mode 100644 index 4da388b32..000000000 --- a/framework/Serialize/test/Horde/Serialize/json_unquoted_keys.phpt +++ /dev/null @@ -1,60 +0,0 @@ ---TEST-- -JSON unquoted keys tests. ---FILE-- -{'0'} = 'tan'; -$ob1->model = 'sedan'; -$ob2->{'0'} = 'red'; -$ob2->model = 'sports'; -$arn = array($ob1, $ob2); -$arn_ja = '[{0:"tan","model":"sedan"},{"0":"red",model:"sports"}]'; - -$arrs->{'1'} = 'one'; -$arrs->{'2'} = 'two'; -$arrs->{'5'} = 'fi"ve'; -$arrs_jo = '{"1":"one",2:"two","5":\'fi"ve\'}'; - -/* Decode tests */ - -// array case - strict: associative array with unquoted keys, nested -// associative arrays, and some numeric keys thrown in -// ...unless the input array has some numeric indeces, in which case the -// behavior is to degrade to a regular array -var_dump(Horde_Serialize::unserialize($arn_ja, Horde_Serialize::JSON)); - -// sparse numeric assoc array: associative array with unquoted keys, -// single-quoted values, numeric keys which are not fully populated in a range -// of 0 to length-1 -// Test a sparsely populated numerically indexed associative array -var_dump(Horde_Serialize::unserialize($arrs_jo, Horde_Serialize::JSON)); - -?> ---EXPECT-- -array(2) { - [0]=> - object(stdClass)(2) { - [0]=> - string(3) "tan" - ["model"]=> - string(5) "sedan" - } - [1]=> - object(stdClass)(2) { - [0]=> - string(3) "red" - ["model"]=> - string(6) "sports" - } -} -object(stdClass)(3) { - [1]=> - string(3) "one" - [2]=> - string(3) "two" - [5]=> - string(5) "fi"ve" -} -- 2.11.0