diff --git a/src/Ary.php b/src/Ary.php index 66f4ab1..d3d751c 100644 --- a/src/Ary.php +++ b/src/Ary.php @@ -146,7 +146,7 @@ class Ary implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable */ public function jsonSerialize() { - return $this->jsonSerialize(); + return $this->all(); } /** diff --git a/test/Test.php b/test/Test.php index 779b318..6ad9a6c 100644 --- a/test/Test.php +++ b/test/Test.php @@ -47,6 +47,7 @@ class Test extends PHPUnit_Framework_TestCase { return array( array('', ''), + array(null, null), array(['ali', 'reza', 'mohammad'], ['ali', 'reza', 'mohammad']), array(['name' => 'ali', 'lastname' => 'reza', 'age' => 30], ['name' => 'ali', 'lastname' => 'reza', 'age' => 30]), array((object)['name' => 'ali', 'lastname' => 'reza', 'age' => 30], (object)['name' => 'ali', 'lastname' => 'reza', 'age' => 30]), @@ -118,6 +119,14 @@ class Test extends PHPUnit_Framework_TestCase } + /** + * @dataProvider various + */ + public function testJsonSerialize($original, $expected) + { + $this->assertEquals(json_encode(new Ary($original)), json_encode((array)$original)); + } + // public function testOffsetExists() // { // $parameters = array(7,8,9,4);