forked from LiveCarta/PayPal-PHP-SDK
Ability to handle missing accesors for unknown objects in json
- JSON body that has objects who do not have Model Getter Setters are handled properly
This commit is contained in:
@@ -98,6 +98,28 @@ class ModelTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Case to determine if the unknown object is returned, it would not add that object to the model.
|
||||
*/
|
||||
public function testUnknownObjectConversion()
|
||||
{
|
||||
PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'disabled'));
|
||||
$json = '{"name":"test","unknown":{ "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'));
|
||||
}
|
||||
|
||||
public function testInvalidMagicMethodWithDisabledValidation()
|
||||
{
|
||||
PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'disabled'));
|
||||
|
||||
@@ -146,5 +146,3 @@ class PayPalCredentialManagerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertAttributeEquals($this->config['acct1.ClientSecret'], 'clientSecret', $cred);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace PayPal\Test\Validation;
|
||||
|
||||
use PayPal\Core\PayPalConfigManager;
|
||||
use PayPal\Test\Common\SimpleClass;
|
||||
use PayPal\Validation\ModelAccessorValidator;
|
||||
|
||||
@@ -27,6 +28,16 @@ class ModelAccessValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'strict'));
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'strict'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @dataProvider positiveProvider
|
||||
|
||||
Reference in New Issue
Block a user