From 3aa13cff4b3e611e0acbb7050c2e8bcb3128530f Mon Sep 17 00:00:00 2001 From: Reza Date: Fri, 6 Nov 2015 09:11:36 +0330 Subject: [PATCH] - updating jsonSerialize --- src/Ary.php | 2 +- test/Test.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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);