diff --git a/lib/PayPal/Common/PayPalModel.php b/lib/PayPal/Common/PayPalModel.php index e216577..895376f 100644 --- a/lib/PayPal/Common/PayPalModel.php +++ b/lib/PayPal/Common/PayPalModel.php @@ -122,7 +122,6 @@ class PayPalModel */ public function __set($key, $value) { - ModelAccessorValidator::validate($this, $this->convertToCamelCase($key)); if (!is_array($value) && $value === null) { $this->__unset($key); } else { @@ -249,13 +248,7 @@ class PayPalModel private function assignValue($key, $value) { - // If we find the getter setter, use that, otherwise use magic method. - if (ModelAccessorValidator::validate($this, $this->convertToCamelCase($key))) { - $setter = "set" . $this->convertToCamelCase($key); - $this->$setter($value); - } else { - $this->__set($key, $value); - } + $this->__set($key, $value); } /** diff --git a/lib/PayPal/Validation/ModelAccessorValidator.php b/lib/PayPal/Validation/ModelAccessorValidator.php deleted file mode 100644 index 10b3d76..0000000 --- a/lib/PayPal/Validation/ModelAccessorValidator.php +++ /dev/null @@ -1,53 +0,0 @@ -get('validation.level'); - if (!empty($mode) && $mode != 'disabled') { - //Check if $attributeName is string - if (gettype($attributeName) !== 'string') { - return false; - } - //If the mode is disabled, bypass the validation - foreach (array('set' . $attributeName, 'get' . $attributeName) as $methodName) { - if (get_class($class) == get_class(new PayPalModel())) { - // Silently return false on cases where you are using PayPalModel instance directly - return false; - } - //Check if both getter and setter exists for given attribute - elseif (!method_exists($class, $methodName)) { - //Delegate the error based on the choice - $className = is_object($class) ? get_class($class) : (string)$class; - $errorMessage = "It seems that $className:$methodName is a new field added to the API response. If not, create an issue at https://github.com/paypal/PayPal-PHP-SDK/issues"; - PayPalLoggingManager::getInstance(__CLASS__)->debug($errorMessage); - if ($mode == 'strict') { - trigger_error($errorMessage, E_USER_NOTICE); - } - return false; - } - } - return true; - } - return false; - } -} diff --git a/sample/bootstrap.php b/sample/bootstrap.php index 763c5b6..34245a4 100644 --- a/sample/bootstrap.php +++ b/sample/bootstrap.php @@ -75,7 +75,6 @@ function getApiContext($clientId, $clientSecret) 'log.LogEnabled' => true, 'log.FileName' => '../PayPal.log', 'log.LogLevel' => 'DEBUG', // PLEASE USE `FINE` LEVEL FOR LOGGING IN LIVE ENVIRONMENTS - 'validation.level' => 'log', 'cache.enabled' => true, // 'http.CURLOPT_CONNECTTIMEOUT' => 30 // 'http.headers.PayPal-Partner-Attribution-Id' => '123123123' diff --git a/sample/sdk_config.ini b/sample/sdk_config.ini index 620f9d4..bec2fc3 100644 --- a/sample/sdk_config.ini +++ b/sample/sdk_config.ini @@ -43,16 +43,6 @@ log.FileName=../PayPal.log ; with a warning message log.LogLevel=INFO -;Validation Configuration -[validation] -; If validation is set to strict, the PayPalModel would make sure that -; there are proper accessors (Getters and Setters) for each model -; objects. Accepted value is -; 'log' : logs the error message to logger only (default) -; 'strict' : throws a php notice message -; 'disable' : disable the validation -validation.level=disable - ;Caching Configuration [cache] ; If Cache is enabled, it stores the access token retrieved from ClientId and Secret from the diff --git a/tests/PayPal/Test/Api/WebhookEventTest.php b/tests/PayPal/Test/Api/WebhookEventTest.php index 02737cd..7918ad0 100644 --- a/tests/PayPal/Test/Api/WebhookEventTest.php +++ b/tests/PayPal/Test/Api/WebhookEventTest.php @@ -209,17 +209,6 @@ class WebhookEventTest extends \PHPUnit_Framework_TestCase WebhookEvent::validateAndGetReceivedEvent('something-invalid', $mockApiContext); } - /** - * @dataProvider mockProvider - * @param $mockApiContext ApiContext - * @expectedException \PHPUnit_Framework_Error_Notice - * @expectedExceptionMessage It seems that PayPal\Api\WebhookEvent:setValid is a new field added to the API response. If not, create an issue at https://github.com/paypal/PayPal-PHP-SDK/issues - */ - public function testValidateWebhookValidJSONWithMissingObject($obj, $mockApiContext) - { - WebhookEvent::validateAndGetReceivedEvent('{"valid":"json"}', $mockApiContext); - } - /** * @dataProvider mockProvider * @param $mockApiContext ApiContext diff --git a/tests/PayPal/Test/Common/ModelTest.php b/tests/PayPal/Test/Common/ModelTest.php index ac90dde..da9063e 100644 --- a/tests/PayPal/Test/Common/ModelTest.php +++ b/tests/PayPal/Test/Common/ModelTest.php @@ -86,20 +86,6 @@ class ModelTest extends \PHPUnit_Framework_TestCase } } - public function testInvalidMagicMethod() - { - $obj = new SimpleClass(); - try { - $obj->invalid = "value2"; - $this->assertEquals($obj->invalid, "value2"); - if (PayPalConfigManager::getInstance()->get('validation.level') == 'strict') { - $this->fail("It should have thrown a Notice Error"); - } - } catch (\PHPUnit_Framework_Error_Notice $ex) { - - } - } - /** * Test Case to determine if the unknown object is returned, it would not add that object to the model. */ diff --git a/tests/PayPal/Test/Validation/ModelAccessValidatorTest.php b/tests/PayPal/Test/Validation/ModelAccessValidatorTest.php deleted file mode 100644 index 43c6cf0..0000000 --- a/tests/PayPal/Test/Validation/ModelAccessValidatorTest.php +++ /dev/null @@ -1,61 +0,0 @@ -addConfigs(array('validation.level' => 'strict')); - } - - public function tearDown() - { - PayPalConfigManager::getInstance()->addConfigs(array('validation.level' => 'strict')); - } - - /** - * - * @dataProvider positiveProvider - */ - public function testValidate($class, $name) - { - $this->assertTrue(ModelAccessorValidator::validate($class, $name)); - } - - /** - * - * @dataProvider invalidProvider - */ - public function testInvalidValidate($class, $name, $exMessage) - { try { - $this->assertFalse(ModelAccessorValidator::validate($class, $name)); - } catch(\Exception $ex) { - $this->assertContains($exMessage, $ex->getMessage()); - } - } -}