Esempio n. 1
0
 public function testSimpleClassObjectInvalidConversion()
 {
     try {
         $json = '{"name":"test","description":"description","invalid":"value"}';
         $obj = new SimpleClass();
         $obj->fromJson($json);
         $this->assertEquals("test", $obj->getName());
         $this->assertEquals("description", $obj->getDescription());
     } catch (\PHPUnit_Framework_Error_Notice $ex) {
         // No need to do anything
     }
 }
Esempio n. 2
0
 public function testSimpleClassConversion()
 {
     $o = new SimpleClass();
     $o->setName("test");
     $o->setDescription("description");
     $this->assertEquals("test", $o->getName());
     $this->assertEquals("description", $o->getDescription());
     $json = $o->toJSON();
     $this->assertEquals('{"name":"test","desc":"description"}', $json);
     $newO = new SimpleClass();
     $newO->fromJson($json);
     $this->assertEquals($o, $newO);
 }
Esempio n. 3
0
 /**
  * Test Case to determine if the unknown object is returned, it would not add that object to the model.
  */
 public function testUnknownArrayConversion()
 {
     PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'disabled'));
     $json = '{"name":"test","unknown":[{"object": { "id" : "123", "object": "456"}}, {"more": { "id" : "123", "object": "456"}}],"description":"description"}';
     $obj = new SimpleClass();
     $obj->fromJson($json);
     $this->assertEquals("test", $obj->getName());
     $this->assertEquals("description", $obj->getDescription());
     $resultJson = $obj->toJSON();
     $this->assertContains("unknown", $resultJson);
     $this->assertContains("id", $resultJson);
     $this->assertContains("object", $resultJson);
     $this->assertContains("123", $resultJson);
     $this->assertContains("456", $resultJson);
     PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'strict'));
 }