2
0
forked from Wavyzz/dolibarr

Fix: Pb in json function for objects

This commit is contained in:
Laurent Destailleur
2012-12-29 12:21:13 +01:00
parent 7d60c33c1a
commit ca6e9643ea
5 changed files with 244 additions and 79 deletions

View File

@@ -28,7 +28,6 @@ global $conf,$user,$langs,$db;
require_once 'PHPUnit/Autoload.php';
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/core/lib/date.lib.php';
require_once dirname(__FILE__).'/../../htdocs/core/lib/json.lib.php';
if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
@@ -478,37 +477,6 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
$this->assertTrue($verifcond);
}
/**
* testJsonencode
*
* @return void
*/
public function testJsonEncode()
{
//$this->sharedFixture
global $conf,$user,$langs,$db;
$this->savconf=$conf;
$this->savuser=$user;
$this->savlangs=$langs;
$this->savdb=$db;
$arraytotest=array(0=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "'));
$encoded=json_encode($arraytotest);
//var_dump($encoded);
$this->assertEquals('[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]',$encoded);
$decoded=json_decode($encoded,true);
//var_dump($decoded);
$this->assertEquals($arraytotest,$decoded);
$encoded=dol_json_encode($arraytotest);
//var_dump($encoded);
$this->assertEquals('[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]',$encoded);
$decoded=dol_json_decode($encoded,true);
//var_dump($decoded);
$this->assertEquals($arraytotest,$decoded);
}
/**
* testGetDefaultTva
*