Enabled Vault Credit Card List API

- Added Credit Card List API Operation
- Updated Credit Card to include new properties
- Updated Tests
- Updated Samples
- Fixed Billing Agreement Sample (Expired Set Date).
This commit is contained in:
Jay Patel
2015-06-25 12:03:08 -05:00
parent 17b5148be8
commit 46d77f15a6
18 changed files with 825 additions and 286 deletions

View File

@@ -18,7 +18,7 @@ class CreditCardListTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"credit-cards":' .CreditCardTest::getJson() . ',"count":123,"next_id":"TestSample"}';
return '{"items":' .CreditCardTest::getJson() . ',"links":' .LinksTest::getJson() . ',"total_items":123,"total_pages":123}';
}
/**
@@ -39,9 +39,10 @@ class CreditCardListTest extends \PHPUnit_Framework_TestCase
{
$obj = new CreditCardList(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getCreditCards());
$this->assertNotNull($obj->getCount());
$this->assertNotNull($obj->getNextId());
$this->assertNotNull($obj->getItems());
$this->assertNotNull($obj->getLinks());
$this->assertNotNull($obj->getTotalItems());
$this->assertNotNull($obj->getTotalPages());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -52,9 +53,10 @@ class CreditCardListTest extends \PHPUnit_Framework_TestCase
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getCreditCards(), CreditCardTest::getObject());
$this->assertEquals($obj->getCount(), 123);
$this->assertEquals($obj->getNextId(), "TestSample");
$this->assertEquals($obj->getItems(), CreditCardTest::getObject());
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
$this->assertEquals($obj->getTotalItems(), 123);
$this->assertEquals($obj->getTotalPages(), 123);
}
}

View File

@@ -2,7 +2,11 @@
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\CreditCardList;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\CreditCard;
/**
@@ -18,7 +22,7 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"id":"TestSample","number":"TestSample","type":"TestSample","expire_month":123,"expire_year":123,"cvv2":"TestSample","first_name":"TestSample","last_name":"TestSample","billing_address":' .AddressTest::getJson() . ',"external_customer_id":"TestSample","state":"TestSample","valid_until":"TestSample","links":' .LinksTest::getJson() . '}';
return '{"id":"TestSample","number":"TestSample","type":"TestSample","expire_month":123,"expire_year":123,"cvv2":"TestSample","first_name":"TestSample","last_name":"TestSample","billing_address":' .AddressTest::getJson() . ',"external_customer_id":"TestSample","merchant_id":"TestSample","payer_id":"TestSample","external_card_id":"TestSample","state":"TestSample","create_time":"TestSample","update_time":"TestSample","valid_until":"TestSample","links":' .LinksTest::getJson() . '}';
}
/**
@@ -49,7 +53,12 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getLastName());
$this->assertNotNull($obj->getBillingAddress());
$this->assertNotNull($obj->getExternalCustomerId());
$this->assertNotNull($obj->getMerchantId());
$this->assertNotNull($obj->getPayerId());
$this->assertNotNull($obj->getExternalCardId());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getValidUntil());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
@@ -72,9 +81,123 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getLastName(), "TestSample");
$this->assertEquals($obj->getBillingAddress(), AddressTest::getObject());
$this->assertEquals($obj->getExternalCustomerId(), "TestSample");
$this->assertEquals($obj->getMerchantId(), "TestSample");
$this->assertEquals($obj->getPayerId(), "TestSample");
$this->assertEquals($obj->getExternalCardId(), "TestSample");
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getValidUntil(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
/**
* @dataProvider mockProvider
* @param CreditCard $obj
*/
public function testCreate($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->create($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param CreditCard $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
CreditCardTest::getJson()
));
$result = $obj->get("creditCardId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param CreditCard $obj
*/
public function testDelete($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
true
));
$result = $obj->delete($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param CreditCard $obj
*/
public function testUpdate($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$patchRequest = PatchRequestTest::getObject();
$result = $obj->update($patchRequest, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param CreditCard $obj
*/
public function testList($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
CreditCardListTest::getJson()
));
$params = array();
$result = $obj->all($params, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
public function mockProvider()
{
$obj = self::getObject();
$mockApiContext = $this->getMockBuilder('ApiContext')
->disableOriginalConstructor()
->getMock();
return array(
array($obj, $mockApiContext),
array($obj, null)
);
}
}

View File

@@ -20,7 +20,7 @@
"body": {
"name": "DPRP",
"description": "Payment with credit Card ",
"start_date": "2015-06-17T9:45:04Z",
"start_date": "2019-06-17T9:45:04Z",
"plan": {
"id": "P-1WJ68935LL406420PUTENA2I"
},

View File

@@ -20,7 +20,7 @@
"body": {
"name": "Base Agreement",
"description": "Basic agreement",
"start_date": "2015-06-17T9:45:04Z",
"start_date": "2019-06-17T9:45:04Z",
"plan": {
"id": "P-1WJ68935LL406420PUTENA2I"
},