From a391143007d6fba63009e21bee5e11229b96ab7d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Jul 2024 02:01:09 +0200 Subject: [PATCH] Removed dol_json_encode/decode in favor of native json_encode/decode --- test/phpunit/JsonLibTest.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/test/phpunit/JsonLibTest.php b/test/phpunit/JsonLibTest.php index 177093e190caa..e792276fcd300 100644 --- a/test/phpunit/JsonLibTest.php +++ b/test/phpunit/JsonLibTest.php @@ -105,10 +105,12 @@ public function testJsonEncode() $decoded = json_decode($encoded, true); $this->assertEquals($arraytotest, $decoded, 'test for json_xxx'); + /* $encoded = dol_json_encode($arraytotest); $this->assertEquals($arrayencodedexpected, $encoded); $decoded = dol_json_decode($encoded, true); $this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx'); + */ // Same test but array start with 2 instead of 0 $arraytotest = array(2 => array('key' => 1,'value' => 'PRODREF','label' => 'Product ref with é and special chars \\ \' "')); @@ -119,20 +121,22 @@ public function testJsonEncode() $decoded = json_decode($encoded, true); $this->assertEquals($arraytotest, $decoded, 'test for json_xxx'); + /* $encoded = dol_json_encode($arraytotest); $this->assertEquals($arrayencodedexpected, $encoded); $decoded = dol_json_decode($encoded, true); $this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx'); + */ - $encoded = dol_json_encode(123); + $encoded = json_encode(123); $this->assertEquals(123, $encoded); - $decoded = dol_json_decode($encoded, true); - $this->assertEquals(123, $decoded, 'test for dol_json_xxx 123'); + $decoded = json_decode($encoded, true); + $this->assertEquals(123, $decoded, 'test for json_xxx 123'); - $encoded = dol_json_encode('abc'); + $encoded = json_encode('abc'); $this->assertEquals('"abc"', $encoded); - $decoded = dol_json_decode($encoded, true); - $this->assertEquals('abc', $decoded, "test for dol_json_xxx 'abc'"); + $decoded = json_decode($encoded, true); + $this->assertEquals('abc', $decoded, "test for json_xxx 'abc'"); // Test with object $now = gmmktime(12, 0, 0, 1, 1, 1970); @@ -140,7 +144,7 @@ public function testJsonEncode() $objecttotest->property1 = 'abc'; $objecttotest->property2 = 1234; $objecttotest->property3 = $now; - $encoded = dol_json_encode($objecttotest); + $encoded = json_encode($objecttotest); $this->assertEquals('{"property1":"abc","property2":1234,"property3":43200}', $encoded); } }