Fix: json emulated function now support utf8 char.

This commit is contained in:
Laurent Destailleur
2012-03-25 14:25:32 +02:00
parent 8e745c88c5
commit 693d0441b3
3 changed files with 363 additions and 121 deletions

View File

@@ -1,20 +1,20 @@
<?php
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
*/
/**
* \file test/phpunit/FunctionsTest.php
@@ -363,5 +363,27 @@ 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);
}
}
?>