]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/JSONTest.php
Added unit tests.
[Github/sugarcrm.git] / tests / include / JSONTest.php
1 <?php
2 require_once 'include/JSON.php';
3
4 class JSONTest extends Sugar_PHPUnit_Framework_TestCase
5 {
6     public function testCanEncodeBasicArray() 
7     {
8         $array = array('foo' => 'bar', 'bar' => 'foo');
9         $json = new JSON();
10         $this->assertEquals(
11             '{"foo":"bar","bar":"foo"}',
12             $json->encode($array)
13         );
14     }
15
16     public function testCanEncodeBasicObjects() 
17     {
18         $obj = new stdClass();
19         $obj->foo = 'bar';
20         $obj->bar = 'foo';
21         $json = new JSON();
22         $this->assertEquals(
23             '{"foo":"bar","bar":"foo"}',
24             $json->encode($obj)
25         );
26     }
27 }