예제 #1
0
 public function testNestedClassConversion()
 {
     $n = new ArrayClass();
     $n->setName("test");
     $n->setDescription("description");
     // 		$n->setTags(array('payment', 'info', 'test'));
     $o = new NestedClass();
     $o->setId('123');
     $o->setInfo($n);
     $this->assertEquals("123", $o->getId());
     $this->assertEquals("test", $o->getInfo()->getName());
     // 		$this->assertEquals(array('payment', 'info', 'test'), $o->getInfo()->getTags());
     $json = $o->toJSON();
     // 		$this->assertEquals('{"id":"123","info":{"name":"test","desc":"description","tags":["payment","info","test"]}}', $json);
     $this->assertEquals('{"id":"123","info":{"name":"test","desc":"description"}}', $json);
     $newO = new NestedClass();
     $newO->fromJson($json);
     $this->assertEquals($o, $newO);
 }