Removed ModelAccessValidator in favor of Forward Compatilibity Issues

- Model Access Validator causes unnecessary issues in existing integrations.
- Causes merchant to break integration if configured incorrectly.
This commit is contained in:
Jay Patel
2015-10-06 18:54:40 -05:00
parent a37b880e96
commit e1e70c0ebd
7 changed files with 1 additions and 158 deletions

View File

@@ -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

View File

@@ -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.
*/

View File

@@ -1,61 +0,0 @@
<?php
namespace PayPal\Test\Validation;
use PayPal\Core\PayPalConfigManager;
use PayPal\Test\Common\SimpleClass;
use PayPal\Validation\ModelAccessorValidator;
class ModelAccessValidatorTest extends \PHPUnit_Framework_TestCase
{
public static function positiveProvider()
{
return array(
array(new SimpleClass(), 'name'),
array(new SimpleClass(), 'description')
);
}
public static function invalidProvider()
{
return array(
array(null, null,'must be an instance of PayPal\Common\PayPalModel, null given'),
array(array(), array() ,'must be an instance of PayPal\Common\PayPalModel, array given'),
array(new SimpleClass(), null,'Error'),
array(new SimpleClass(), array(),'Error'),
array(null, 'name','must be an instance of PayPal\Common\PayPalModel, null given'),
array(new SimpleClass(),'notfound', 'It seems that PayPal\Test\Common\SimpleClass:setnotfound is a new field added to the API response')
);
}
public function setUp()
{
PayPalConfigManager::getInstance()->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());
}
}
}