Updated Payment APIs

- Updated SDK Models to latest Payment APIs
- Updated Unit Tests
This commit is contained in:
Jay Patel
2015-02-26 15:03:59 -06:00
parent 241d80cd17
commit 3e43f93f9b
93 changed files with 6079 additions and 1735 deletions

View File

@@ -18,7 +18,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"line1":"TestSample","line2":"TestSample","city":"TestSample","country_code":"TestSample","postal_code":"TestSample","state":"TestSample","phone":"TestSample"}';
return '{"line1":"TestSample","line2":"TestSample","city":"TestSample","country_code":"TestSample","postal_code":"TestSample","state":"TestSample","phone":"TestSample","normalization_status":"TestSample","status":"TestSample"}';
}
/**
@@ -46,6 +46,8 @@ class AddressTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getPostalCode());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getPhone());
$this->assertNotNull($obj->getNormalizationStatus());
$this->assertNotNull($obj->getStatus());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -63,6 +65,8 @@ class AddressTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getPostalCode(), "TestSample");
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getPhone(), "TestSample");
$this->assertEquals($obj->getNormalizationStatus(), "TestSample");
$this->assertEquals($obj->getStatus(), "TestSample");
}
}

View File

@@ -2,49 +2,61 @@
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Converter\FormatConverter;
use PayPal\Validation\NumericValidator;
use PayPal\Api\Amount;
use PayPal\Test\Constants;
/**
* Class Amount
*
* @package PayPal\Test\Api
*/
class AmountTest extends \PHPUnit_Framework_TestCase
{
private $amounts;
public static $currency = "USD";
public static $total = "1.12";
public static function createAmount()
/**
* Gets Json String of Object Amount
* @return string
*/
public static function getJson()
{
$amount = new Amount();
$amount->setCurrency(self::$currency);
$amount->setTotal(self::$total);
return $amount;
return '{"currency":"TestSample","total":"12.34","details":' .DetailsTest::getJson() . '}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Amount
*/
public static function getObject()
{
$this->amounts['partial'] = self::createAmount();
$amount = self::createAmount();
$amount->setDetails(DetailsTest::createAmountDetails());
$this->amounts['full'] = $amount;
return new Amount(self::getJson());
}
public function testGetterSetter()
/**
* Tests for Serialization and Deserialization Issues
* @return Amount
*/
public function testSerializationDeserialization()
{
$this->assertEquals(self::$currency, $this->amounts['partial']->getCurrency());
$this->assertEquals(self::$total, $this->amounts['partial']->getTotal());
$this->assertEquals(DetailsTest::$fee, $this->amounts['full']->getDetails()->getFee());
$obj = new Amount(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getCurrency());
$this->assertNotNull($obj->getTotal());
$this->assertNotNull($obj->getDetails());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Amount $obj
*/
public function testGetters($obj)
{
$a1 = $this->amounts['partial'];
$a2 = new Amount();
$a2->fromJson($a1->toJson());
$this->assertEquals($a1, $a2);
$this->assertEquals($obj->getCurrency(), "TestSample");
$this->assertEquals($obj->getTotal(), "12.34");
$this->assertEquals($obj->getDetails(), DetailsTest::getObject());
}
}
}

View File

@@ -1,201 +1,176 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Api\Amount;
use PayPal\Api\Authorization;
use PayPal\Api\Links;
use PayPal\Api\PayerInfo;
use PayPal\Test\Constants;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Address;
use PayPal\Api\Payer;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\Capture;
use PayPal\Api\CreditCard;
use PayPal\Api\Payment;
use PayPal\Api\FundingInstrument;
use PayPal\Api\Transaction;
use PayPal\Exception\PayPalConnectionException;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\Authorization;
/**
* Class Authorization
*
* @package PayPal\Test\Api
*/
class AuthorizationTest extends \PHPUnit_Framework_TestCase
{
private $authorizations = array();
public static $create_time = "2013-02-28T00:00:00Z";
public static $update_time = "2013-03-28T00:00:00Z";
public static $id = "AUTH-123";
public static $state = "Created";
public static $parent_payment = "PAY-12345";
public static $valid_until = "2013-04-28T00:00:00Z";
public static $clearing_time = "2013-04-28T00:00:00Z";
public static $currency = "USD";
public static $total = "1.12";
public static $href = "USD";
public static $rel = "1.12";
public static $method = "1.12";
public static function createAuthorization()
/**
* Gets Json String of Object Authorization
* @return string
*/
public static function getJson()
{
$authorization = new Authorization();
$authorization->setCreateTime(self::$create_time);
$authorization->setId(self::$id);
$authorization->setState(self::$state);
$authorization->setClearingTime(self::$clearing_time);
$authorization->setAmount(AmountTest::createAmount());
$authorization->setLinks(array(LinksTest::getObject()));
return $authorization;
}
public static function authorize()
{
$addr = new Address();
$addr->setLine1("3909 Witmer Road");
$addr->setLine2("Niagara Falls");
$addr->setCity("Niagara Falls");
$addr->setState("NY");
$addr->setPostalCode("14305");
$addr->setCountryCode("US");
$addr->setPhone("716-298-1822");
$card = new CreditCard();
$card->setType("visa");
$card->setNumber("4417119669820331");
$card->setExpireMonth("11");
$card->setExpireYear("2019");
$card->setCvv2("012");
$card->setFirstName("Joe");
$card->setLastName("Shopper");
$card->setBillingAddress($addr);
$fi = new FundingInstrument();
$fi->setCreditCard($card);
$payer = new Payer();
$payer->setPaymentMethod("credit_card");
$payer->setFundingInstruments(array($fi));
$amount = new Amount();
$amount->setCurrency("USD");
$amount->setTotal("1.00");
$transaction = new Transaction();
$transaction->setAmount($amount);
$transaction->setDescription("This is the payment description.");
$payment = new Payment();
$payment->setIntent("authorize");
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
$paymnt = $payment->create();
$resArray = $paymnt->toArray();
return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id'];
}
public function setup()
{
$authorization = new Authorization();
$authorization->setCreateTime(self::$create_time);
$authorization->setUpdateTime(self::$update_time);
$authorization->setId(self::$id);
$authorization->setState(self::$state);
$authorization->setParentPayment(self::$parent_payment);
$authorization->setValidUntil(self::$valid_until);
$authorization->setClearingTime(self::$clearing_time);
$this->authorizations['partial'] = $authorization;
$this->authorizations['full'] = self::createAuthorization();
}
public function testGetterSetter()
{
/** @var Authorization $authorization */
$authorization = $this->authorizations['partial'];
$this->assertEquals(self::$create_time, $authorization->getCreateTime());
$this->assertEquals(self::$update_time, $authorization->getUpdateTime());
$this->assertEquals(self::$id, $authorization->getId());
$this->assertEquals(self::$state, $authorization->getState());
$this->assertEquals(self::$parent_payment, $authorization->getParentPayment());
$this->assertEquals(self::$valid_until, $authorization->getValidUntil());
$this->assertEquals(self::$clearing_time, $authorization->getClearingTime());
$authorization = $this->authorizations['full'];
$this->assertEquals(AmountTest::$currency, $authorization->getAmount()->getCurrency());
$this->assertEquals(1, count($authorization->getLinks()));
}
public function testSerializeDeserialize()
{
$a1 = $this->authorizations['partial'];
$a2 = new Authorization();
$a2->fromJson($a1->toJson());
$this->assertEquals($a1, $a2);
return '{"id":"TestSample","amount":' .AmountTest::getJson() . ',"payment_mode":"TestSample","state":"TestSample","reason_code":"TestSample","pending_reason":"TestSample","protection_eligibility":"TestSample","protection_eligibility_type":"TestSample","fmf_details":' .FmfDetailsTest::getJson() . ',"parent_payment":"TestSample","valid_until":"TestSample","create_time":"TestSample","update_time":"TestSample","links":' .LinksTest::getJson() . '}';
}
/**
* @group integration
* Gets Object Instance with Json data filled in
* @return Authorization
*/
public function testOperations()
public static function getObject()
{
try {
$authId = self::authorize();
$auth = Authorization::get($authId);
$this->assertNotNull($auth->getId());
return new Authorization(self::getJson());
}
$amount = new Amount();
$amount->setCurrency("USD");
$amount->setTotal("1.00");
$captur = new Capture();
$captur->setId($authId);
$captur->setAmount($amount);
$capt = $auth->capture($captur);
$this->assertNotNull($capt->getId());
$authId = self::authorize();
$auth = Authorization::get($authId);
$void = $auth->void();
$this->assertNotNull($void->getId());
$auth->setId(null);
try {
$auth->void();
} catch (\InvalidArgumentException $ex) {
$this->assertEquals($ex->getMessage(), "Id cannot be null");
}
} catch (PayPalConnectionException $ex) {
$this->markTestSkipped(
'Tests failing because of intermittent failures in Paypal Sandbox environment.' . $ex->getMessage()
);
}
/**
* Tests for Serialization and Deserialization Issues
* @return Authorization
*/
public function testSerializationDeserialization()
{
$obj = new Authorization(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getPaymentMode());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getReasonCode());
$this->assertNotNull($obj->getPendingReason());
$this->assertNotNull($obj->getProtectionEligibility());
$this->assertNotNull($obj->getProtectionEligibilityType());
$this->assertNotNull($obj->getFmfDetails());
$this->assertNotNull($obj->getParentPayment());
$this->assertNotNull($obj->getValidUntil());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @group integration
* @depends testSerializationDeserialization
* @param Authorization $obj
*/
public function testReauthorize()
public function testGetters($obj)
{
$authorization = Authorization::get('7GH53639GA425732B');
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getAmount(), AmountTest::getObject());
$this->assertEquals($obj->getPaymentMode(), "TestSample");
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getReasonCode(), "TestSample");
$this->assertEquals($obj->getPendingReason(), "TestSample");
$this->assertEquals($obj->getProtectionEligibility(), "TestSample");
$this->assertEquals($obj->getProtectionEligibilityType(), "TestSample");
$this->assertEquals($obj->getFmfDetails(), FmfDetailsTest::getObject());
$this->assertEquals($obj->getParentPayment(), "TestSample");
$this->assertEquals($obj->getValidUntil(), "TestSample");
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
$amount = new Amount();
$amount->setCurrency("USD");
$amount->setTotal("1.00");
$authorization->setAmount($amount);
try {
$authorization->reauthorize();
} catch (PayPalConnectionException $ex) {
//var_dump($ex->getMessage());
$this->assertEquals(strpos($ex->getMessage(), "500"), false);
}
/**
* @dataProvider mockProvider
* @param Authorization $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$authorization->setId(null);
try {
$authorization->reauthorize();
} catch (\InvalidArgumentException $ex) {
$this->assertEquals($ex->getMessage(), "Id cannot be null");
}
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
AuthorizationTest::getJson()
));
$result = $obj->get("authorizationId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Authorization $obj
*/
public function testCapture($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
CaptureTest::getJson()
));
$capture = CaptureTest::getObject();
$result = $obj->capture($capture, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Authorization $obj
*/
public function testVoid($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->void($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Authorization $obj
*/
public function testReauthorize($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->reauthorize($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

@@ -1,101 +1,128 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Api\Capture;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\Refund;
use PayPal\Api\Authorization;
use PayPal\Api\Amount;
use PayPal\Exception\PayPalConnectionException;
use PayPal\Test\Constants;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\Capture;
/**
* Class Capture
*
* @package PayPal\Test\Api
*/
class CaptureTest extends \PHPUnit_Framework_TestCase
{
private $captures;
public static $authorization_id = "AUTH-123";
public static $create_time = "2013-02-28T00:00:00Z";
public static $id = "C-5678";
public static $parent_payment = "PAY-123";
public static $state = "Created";
public static function createCapture()
/**
* Gets Json String of Object Capture
* @return string
*/
public static function getJson()
{
$capture = new Capture();
$capture->setCreateTime(self::$create_time);
$capture->setId(self::$id);
$capture->setParentPayment(self::$parent_payment);
$capture->setState(self::$state);
return $capture;
}
public function setup()
{
$this->captures['partial'] = self::createCapture();
$capture = self::createCapture();
$capture->setAmount(AmountTest::createAmount());
$capture->setLinks(array(LinksTest::getObject()));
$this->captures['full'] = $capture;
}
public function testGetterSetter()
{
$this->assertEquals(self::$create_time, $this->captures['partial']->getCreateTime());
$this->assertEquals(self::$id, $this->captures['partial']->getId());
$this->assertEquals(self::$parent_payment, $this->captures['partial']->getParentPayment());
$this->assertEquals(self::$state, $this->captures['partial']->getState());
$this->assertEquals(AmountTest::$currency, $this->captures['full']->getAmount()->getCurrency());
$links = $this->captures['full']->getLinks();
}
public function testSerializeDeserialize()
{
$c1 = $this->captures['partial'];
$c2 = new Capture();
$c2->fromJson($c1->toJson());
$this->assertEquals($c1, $c2);
return '{"id":"TestSample","amount":' .AmountTest::getJson() . ',"is_final_capture":true,"state":"TestSample","parent_payment":"TestSample","transaction_fee":' .CurrencyTest::getJson() . ',"create_time":"TestSample","update_time":"TestSample","links":' .LinksTest::getJson() . '}';
}
/**
* @group integration
* Gets Object Instance with Json data filled in
* @return Capture
*/
public function testOperations()
public static function getObject()
{
try {
$authId = AuthorizationTest::authorize();
$auth = Authorization::get($authId);
return new Capture(self::getJson());
}
$amount = new Amount();
$amount->setCurrency("USD");
$amount->setTotal("1.00");
$captr = new Capture();
$captr->setId($authId);
$captr->setAmount($amount);
/**
* Tests for Serialization and Deserialization Issues
* @return Capture
*/
public function testSerializationDeserialization()
{
$obj = new Capture(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getIsFinalCapture());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getParentPayment());
$this->assertNotNull($obj->getTransactionFee());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
$capt = $auth->capture($captr);
$captureId = $capt->getId();
$this->assertNotNull($captureId);
/**
* @depends testSerializationDeserialization
* @param Capture $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getAmount(), AmountTest::getObject());
$this->assertEquals($obj->getIsFinalCapture(), true);
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getParentPayment(), "TestSample");
$this->assertEquals($obj->getTransactionFee(), CurrencyTest::getObject());
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
$refund = new Refund();
$refund->setId($captureId);
$refund->setAmount($amount);
$capture = Capture::get($captureId);
$this->assertNotNull($capture->getId());
/**
* @dataProvider mockProvider
* @param Capture $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$retund = $capture->refund($refund);
$this->assertNotNull($retund->getId());
} catch (PayPalConnectionException $ex) {
$this->markTestSkipped(
'Tests failing because of intermittent failures in Paypal Sandbox environment.' . $ex->getMessage()
);
}
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
CaptureTest::getJson()
));
$result = $obj->get("captureId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Capture $obj
*/
public function testRefund($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
RefundTest::getJson()
));
$refund = RefundTest::getObject();
$result = $obj->refund($refund, $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

@@ -0,0 +1,57 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\CarrierAccountToken;
/**
* Class CarrierAccountToken
*
* @package PayPal\Test\Api
*/
class CarrierAccountTokenTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object CarrierAccountToken
* @return string
*/
public static function getJson()
{
return '{"carrier_account_id":"TestSample","external_customer_id":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return CarrierAccountToken
*/
public static function getObject()
{
return new CarrierAccountToken(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return CarrierAccountToken
*/
public function testSerializationDeserialization()
{
$obj = new CarrierAccountToken(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getCarrierAccountId());
$this->assertNotNull($obj->getExternalCustomerId());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param CarrierAccountToken $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getCarrierAccountId(), "TestSample");
$this->assertEquals($obj->getExternalCustomerId(), "TestSample");
}
}

View File

@@ -0,0 +1,94 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\CartBase;
/**
* Class CartBase
*
* @package PayPal\Test\Api
*/
class CartBaseTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object CartBase
* @return string
*/
public static function getJson()
{
return '{"amount":' .AmountTest::getJson() . ',"payee":' .PayeeTest::getJson() . ',"description":"TestSample","note_to_payee":"TestSample","custom":"TestSample","invoice_number":"TestSample","soft_descriptor":"TestSample","payment_options":' .PaymentOptionsTest::getJson() . ',"item_list":' .ItemListTest::getJson() . ',"notify_url":"http://www.google.com","order_url":"http://www.google.com"}';
}
/**
* Gets Object Instance with Json data filled in
* @return CartBase
*/
public static function getObject()
{
return new CartBase(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return CartBase
*/
public function testSerializationDeserialization()
{
$obj = new CartBase(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getPayee());
$this->assertNotNull($obj->getDescription());
$this->assertNotNull($obj->getNoteToPayee());
$this->assertNotNull($obj->getCustom());
$this->assertNotNull($obj->getInvoiceNumber());
$this->assertNotNull($obj->getSoftDescriptor());
$this->assertNotNull($obj->getPaymentOptions());
$this->assertNotNull($obj->getItemList());
$this->assertNotNull($obj->getNotifyUrl());
$this->assertNotNull($obj->getOrderUrl());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param CartBase $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getAmount(), AmountTest::getObject());
$this->assertEquals($obj->getPayee(), PayeeTest::getObject());
$this->assertEquals($obj->getDescription(), "TestSample");
$this->assertEquals($obj->getNoteToPayee(), "TestSample");
$this->assertEquals($obj->getCustom(), "TestSample");
$this->assertEquals($obj->getInvoiceNumber(), "TestSample");
$this->assertEquals($obj->getSoftDescriptor(), "TestSample");
$this->assertEquals($obj->getPaymentOptions(), PaymentOptionsTest::getObject());
$this->assertEquals($obj->getItemList(), ItemListTest::getObject());
$this->assertEquals($obj->getNotifyUrl(), "http://www.google.com");
$this->assertEquals($obj->getOrderUrl(), "http://www.google.com");
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage NotifyUrl is not a fully qualified URL
*/
public function testUrlValidationForNotifyUrl()
{
$obj = new CartBase();
$obj->setNotifyUrl(null);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage OrderUrl is not a fully qualified URL
*/
public function testUrlValidationForOrderUrl()
{
$obj = new CartBase();
$obj->setOrderUrl(null);
}
}

View File

@@ -2,10 +2,7 @@
namespace PayPal\Test\Api;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PayPalRestCall;
use PayPal\Common\PayPalModel;
use PayPal\Api\CreditCard;
/**
@@ -21,7 +18,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":123,"first_name":"TestSample","last_name":"TestSample","billing_address":' .AddressTest::getJson() . ',"external_customer_id":"TestSample","state":"TestSample","valid_until":"TestSample","create_time":"TestSample","update_time":"TestSample"}';
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() . '}';
}
/**
@@ -54,8 +51,6 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getExternalCustomerId());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getValidUntil());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
@@ -72,104 +67,14 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getType(), "TestSample");
$this->assertEquals($obj->getExpireMonth(), 123);
$this->assertEquals($obj->getExpireYear(), 123);
$this->assertEquals($obj->getCvv2(), 123);
$this->assertEquals($obj->getCvv2(), "TestSample");
$this->assertEquals($obj->getFirstName(), "TestSample");
$this->assertEquals($obj->getLastName(), "TestSample");
$this->assertEquals($obj->getBillingAddress(), AddressTest::getObject());
$this->assertEquals($obj->getExternalCustomerId(), "TestSample");
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getValidUntil(), "TestSample");
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
/**
* @dataProvider mockProvider
* @param CreditCard $obj
*/
public function testCreate($obj, $mockApiContext)
{
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPayPalRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->create($mockApiContext, $mockPayPalRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param CreditCard $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPayPalRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
CreditCardTest::getJson()
));
$result = $obj->get("creditCardId", $mockApiContext, $mockPayPalRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param CreditCard $obj
*/
public function testDelete($obj, $mockApiContext)
{
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPayPalRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
true
));
$result = $obj->delete($mockApiContext, $mockPayPalRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param CreditCard $obj
*/
public function testUpdate($obj, $mockApiContext)
{
$mockPayPalRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPayPalRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->update($mockApiContext, $mockPayPalRestCall);
$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

@@ -18,7 +18,7 @@ class CreditTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"id":"TestSample","type":"TestSample","terms":"TestSample"}';
return '{"id":"TestSample","type":"TestSample"}';
}
/**
@@ -41,7 +41,6 @@ class CreditTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getType());
$this->assertNotNull($obj->getTerms());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -54,7 +53,6 @@ class CreditTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getType(), "TestSample");
$this->assertEquals($obj->getTerms(), "TestSample");
}
}

View File

@@ -0,0 +1,89 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\CurrencyConversion;
/**
* Class CurrencyConversion
*
* @package PayPal\Test\Api
*/
class CurrencyConversionTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object CurrencyConversion
* @return string
*/
public static function getJson()
{
return '{"conversion_date":"TestSample","from_currency":"TestSample","from_amount":"TestSample","to_currency":"TestSample","to_amount":"TestSample","conversion_type":"TestSample","conversion_type_changeable":true,"web_url":"http://www.google.com","links":' .LinksTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return CurrencyConversion
*/
public static function getObject()
{
return new CurrencyConversion(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return CurrencyConversion
*/
public function testSerializationDeserialization()
{
$obj = new CurrencyConversion(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getConversionDate());
$this->assertNotNull($obj->getFromCurrency());
$this->assertNotNull($obj->getFromAmount());
$this->assertNotNull($obj->getToCurrency());
$this->assertNotNull($obj->getToAmount());
$this->assertNotNull($obj->getConversionType());
$this->assertNotNull($obj->getConversionTypeChangeable());
$this->assertNotNull($obj->getWebUrl());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param CurrencyConversion $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getConversionDate(), "TestSample");
$this->assertEquals($obj->getFromCurrency(), "TestSample");
$this->assertEquals($obj->getFromAmount(), "TestSample");
$this->assertEquals($obj->getToCurrency(), "TestSample");
$this->assertEquals($obj->getToAmount(), "TestSample");
$this->assertEquals($obj->getConversionType(), "TestSample");
$this->assertEquals($obj->getConversionTypeChangeable(), true);
$this->assertEquals($obj->getWebUrl(), "http://www.google.com");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage WebUrl is not a fully qualified URL
*/
public function testUrlValidationForWebUrl()
{
$obj = new CurrencyConversion();
$obj->setWebUrl(null);
}
public function testUrlValidationForWebUrlDeprecated()
{
$obj = new CurrencyConversion();
$obj->setWebUrl(null);
$this->assertNull($obj->getWebUrl());
}
}

View File

@@ -54,7 +54,7 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase
public function testGetters($obj)
{
$this->assertEquals($obj->getCurrency(), "TestSample");
$this->assertEquals($obj->getValue(), "TestSample");
$this->assertEquals($obj->getValue(), "12.34");
}
}

View File

@@ -1,50 +1,71 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Converter\FormatConverter;
use PayPal\Validation\NumericValidator;
use PayPal\Api\Details;
use PayPal\Test\Constants;
/**
* Class Details
*
* @package PayPal\Test\Api
*/
class DetailsTest extends \PHPUnit_Framework_TestCase
{
private $amountDetails;
public static $subtotal = "2.00";
public static $tax = "1.12";
public static $shipping = "3.15";
public static $fee = "4.99";
public static function createAmountDetails()
/**
* Gets Json String of Object Details
* @return string
*/
public static function getJson()
{
$amountDetails = new Details();
$amountDetails->setSubtotal(self::$subtotal);
$amountDetails->setTax(self::$tax);
$amountDetails->setShipping(self::$shipping);
$amountDetails->setFee(self::$fee);
return $amountDetails;
return '{"subtotal":"12.34","shipping":"12.34","tax":"12.34","handling_fee":"12.34","shipping_discount":"12.34","insurance":"12.34","gift_wrap":"12.34","fee":"12.34"}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Details
*/
public static function getObject()
{
$this->amountDetails = self::createAmountDetails();
return new Details(self::getJson());
}
public function testGetterSetters()
/**
* Tests for Serialization and Deserialization Issues
* @return Details
*/
public function testSerializationDeserialization()
{
$this->assertEquals(self::$subtotal, $this->amountDetails->getSubtotal());
$this->assertEquals(self::$tax, $this->amountDetails->getTax());
$this->assertEquals(self::$shipping, $this->amountDetails->getShipping());
$this->assertEquals(self::$fee, $this->amountDetails->getFee());
$obj = new Details(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getSubtotal());
$this->assertNotNull($obj->getShipping());
$this->assertNotNull($obj->getTax());
$this->assertNotNull($obj->getHandlingFee());
$this->assertNotNull($obj->getShippingDiscount());
$this->assertNotNull($obj->getInsurance());
$this->assertNotNull($obj->getGiftWrap());
$this->assertNotNull($obj->getFee());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Details $obj
*/
public function testGetters($obj)
{
$a1 = $this->amountDetails;
$a2 = new Details();
$a2->fromJson($a1->toJson());
$this->assertEquals($a1, $a2);
$this->assertEquals($obj->getSubtotal(), "12.34");
$this->assertEquals($obj->getShipping(), "12.34");
$this->assertEquals($obj->getTax(), "12.34");
$this->assertEquals($obj->getHandlingFee(), "12.34");
$this->assertEquals($obj->getShippingDiscount(), "12.34");
$this->assertEquals($obj->getInsurance(), "12.34");
$this->assertEquals($obj->getGiftWrap(), "12.34");
$this->assertEquals($obj->getFee(), "12.34");
}
}
}

View File

@@ -18,7 +18,7 @@ class ErrorDetailsTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"field":"TestSample","issue":"TestSample"}';
return '{"field":"TestSample","issue":"TestSample","purchase_unit_reference_id":"TestSample","code":"TestSample"}';
}
/**
@@ -41,6 +41,8 @@ class ErrorDetailsTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj);
$this->assertNotNull($obj->getField());
$this->assertNotNull($obj->getIssue());
$this->assertNotNull($obj->getPurchaseUnitReferenceId());
$this->assertNotNull($obj->getCode());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -53,6 +55,8 @@ class ErrorDetailsTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals($obj->getField(), "TestSample");
$this->assertEquals($obj->getIssue(), "TestSample");
$this->assertEquals($obj->getPurchaseUnitReferenceId(), "TestSample");
$this->assertEquals($obj->getCode(), "TestSample");
}
}

View File

@@ -18,7 +18,7 @@ class ErrorTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"name":"TestSample","debug_id":"TestSample","message":"TestSample","information_link":"TestSample","details":' .ErrorDetailsTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
return '{"name":"TestSample","purchase_unit_reference_id":"TestSample","debug_id":"TestSample","message":"TestSample","code":"TestSample","information_link":"TestSample","details":' .ErrorDetailsTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
}
/**
@@ -40,8 +40,10 @@ class ErrorTest extends \PHPUnit_Framework_TestCase
$obj = new Error(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getPurchaseUnitReferenceId());
$this->assertNotNull($obj->getDebugId());
$this->assertNotNull($obj->getMessage());
$this->assertNotNull($obj->getCode());
$this->assertNotNull($obj->getInformationLink());
$this->assertNotNull($obj->getDetails());
$this->assertNotNull($obj->getLinks());
@@ -56,8 +58,10 @@ class ErrorTest extends \PHPUnit_Framework_TestCase
public function testGetters($obj)
{
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getPurchaseUnitReferenceId(), "TestSample");
$this->assertEquals($obj->getDebugId(), "TestSample");
$this->assertEquals($obj->getMessage(), "TestSample");
$this->assertEquals($obj->getCode(), "TestSample");
$this->assertEquals($obj->getInformationLink(), "TestSample");
$this->assertEquals($obj->getDetails(), ErrorDetailsTest::getObject());
$this->assertEquals($obj->getLinks(), LinksTest::getObject());

View File

@@ -0,0 +1,62 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\FmfDetails;
/**
* Class FmfDetails
*
* @package PayPal\Test\Api
*/
class FmfDetailsTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object FmfDetails
* @return string
*/
public static function getJson()
{
return '{"filter_type":"TestSample","filter_id":"TestSample","name":"TestSample","description":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return FmfDetails
*/
public static function getObject()
{
return new FmfDetails(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return FmfDetails
*/
public function testSerializationDeserialization()
{
$obj = new FmfDetails(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getFilterType());
$this->assertNotNull($obj->getFilterId());
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getDescription());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param FmfDetails $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getFilterType(), "TestSample");
$this->assertEquals($obj->getFilterId(), "TestSample");
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getDescription(), "TestSample");
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\FundingDetail;
/**
* Class FundingDetail
*
* @package PayPal\Test\Api
*/
class FundingDetailTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object FundingDetail
* @return string
*/
public static function getJson()
{
return '{"clearing_time":"TestSample","payment_hold_date":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return FundingDetail
*/
public static function getObject()
{
return new FundingDetail(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return FundingDetail
*/
public function testSerializationDeserialization()
{
$obj = new FundingDetail(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getClearingTime());
$this->assertNotNull($obj->getPaymentHoldDate());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param FundingDetail $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getClearingTime(), "TestSample");
$this->assertEquals($obj->getPaymentHoldDate(), "TestSample");
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\FundingOption;
/**
* Class FundingOption
*
* @package PayPal\Test\Api
*/
class FundingOptionTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object FundingOption
* @return string
*/
public static function getJson()
{
return '{"id":"TestSample","funding_sources":' .FundingSourceTest::getJson() . ',"backup_funding_instrument":' .FundingInstrumentTest::getJson() . ',"currency_conversion":' .CurrencyConversionTest::getJson() . ',"installment_info":' .InstallmentInfoTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return FundingOption
*/
public static function getObject()
{
return new FundingOption(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return FundingOption
*/
public function testSerializationDeserialization()
{
$obj = new FundingOption(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getFundingSources());
$this->assertNotNull($obj->getBackupFundingInstrument());
$this->assertNotNull($obj->getCurrencyConversion());
$this->assertNotNull($obj->getInstallmentInfo());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param FundingOption $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getFundingSources(), FundingSourceTest::getObject());
$this->assertEquals($obj->getBackupFundingInstrument(), FundingInstrumentTest::getObject());
$this->assertEquals($obj->getCurrencyConversion(), CurrencyConversionTest::getObject());
$this->assertEquals($obj->getInstallmentInfo(), InstallmentInfoTest::getObject());
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
}

View File

@@ -0,0 +1,71 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\FundingSource;
/**
* Class FundingSource
*
* @package PayPal\Test\Api
*/
class FundingSourceTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object FundingSource
* @return string
*/
public static function getJson()
{
return '{"funding_mode":"TestSample","funding_instrument_type":"TestSample","soft_descriptor":"TestSample","amount":' .CurrencyTest::getJson() . ',"legal_text":"TestSample","funding_detail":' .FundingDetailTest::getJson() . ',"additional_text":"TestSample","extends":' .FundingInstrumentTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return FundingSource
*/
public static function getObject()
{
return new FundingSource(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return FundingSource
*/
public function testSerializationDeserialization()
{
$obj = new FundingSource(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getFundingMode());
$this->assertNotNull($obj->getFundingInstrumentType());
$this->assertNotNull($obj->getSoftDescriptor());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getLegalText());
$this->assertNotNull($obj->getFundingDetail());
$this->assertNotNull($obj->getAdditionalText());
$this->assertNotNull($obj->getExtends());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param FundingSource $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getFundingMode(), "TestSample");
$this->assertEquals($obj->getFundingInstrumentType(), "TestSample");
$this->assertEquals($obj->getSoftDescriptor(), "TestSample");
$this->assertEquals($obj->getAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getLegalText(), "TestSample");
$this->assertEquals($obj->getFundingDetail(), FundingDetailTest::getObject());
$this->assertEquals($obj->getAdditionalText(), "TestSample");
$this->assertEquals($obj->getExtends(), FundingInstrumentTest::getObject());
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
}

View File

@@ -0,0 +1,81 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\Incentive;
/**
* Class Incentive
*
* @package PayPal\Test\Api
*/
class IncentiveTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Incentive
* @return string
*/
public static function getJson()
{
return '{"id":"TestSample","code":"TestSample","name":"TestSample","description":"TestSample","minimum_purchase_amount":' .CurrencyTest::getJson() . ',"logo_image_url":"http://www.google.com","expiry_date":"TestSample","type":"TestSample","terms":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return Incentive
*/
public static function getObject()
{
return new Incentive(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Incentive
*/
public function testSerializationDeserialization()
{
$obj = new Incentive(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getCode());
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getDescription());
$this->assertNotNull($obj->getMinimumPurchaseAmount());
$this->assertNotNull($obj->getLogoImageUrl());
$this->assertNotNull($obj->getExpiryDate());
$this->assertNotNull($obj->getType());
$this->assertNotNull($obj->getTerms());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Incentive $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getCode(), "TestSample");
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getDescription(), "TestSample");
$this->assertEquals($obj->getMinimumPurchaseAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getLogoImageUrl(), "http://www.google.com");
$this->assertEquals($obj->getExpiryDate(), "TestSample");
$this->assertEquals($obj->getType(), "TestSample");
$this->assertEquals($obj->getTerms(), "TestSample");
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage LogoImageUrl is not a fully qualified URL
*/
public function testUrlValidationForLogoImageUrl()
{
$obj = new Incentive();
$obj->setLogoImageUrl(null);
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\InstallmentInfo;
/**
* Class InstallmentInfo
*
* @package PayPal\Test\Api
*/
class InstallmentInfoTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object InstallmentInfo
* @return string
*/
public static function getJson()
{
return '{"installment_id":"TestSample","network":"TestSample","issuer":"TestSample","installment_options":' .InstallmentOptionTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return InstallmentInfo
*/
public static function getObject()
{
return new InstallmentInfo(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return InstallmentInfo
*/
public function testSerializationDeserialization()
{
$obj = new InstallmentInfo(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getInstallmentId());
$this->assertNotNull($obj->getNetwork());
$this->assertNotNull($obj->getIssuer());
$this->assertNotNull($obj->getInstallmentOptions());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param InstallmentInfo $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getInstallmentId(), "TestSample");
$this->assertEquals($obj->getNetwork(), "TestSample");
$this->assertEquals($obj->getIssuer(), "TestSample");
$this->assertEquals($obj->getInstallmentOptions(), InstallmentOptionTest::getObject());
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\InstallmentOption;
/**
* Class InstallmentOption
*
* @package PayPal\Test\Api
*/
class InstallmentOptionTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object InstallmentOption
* @return string
*/
public static function getJson()
{
return '{"term":123,"monthly_payment":' .CurrencyTest::getJson() . ',"discount_amount":' .CurrencyTest::getJson() . ',"discount_percentage":"12.34"}';
}
/**
* Gets Object Instance with Json data filled in
* @return InstallmentOption
*/
public static function getObject()
{
return new InstallmentOption(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return InstallmentOption
*/
public function testSerializationDeserialization()
{
$obj = new InstallmentOption(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getTerm());
$this->assertNotNull($obj->getMonthlyPayment());
$this->assertNotNull($obj->getDiscountAmount());
$this->assertNotNull($obj->getDiscountPercentage());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param InstallmentOption $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getTerm(), 123);
$this->assertEquals($obj->getMonthlyPayment(), CurrencyTest::getObject());
$this->assertEquals($obj->getDiscountAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getDiscountPercentage(), "12.34");
}
}

View File

@@ -1,83 +1,60 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Api\Item;
use PayPal\Common\PayPalModel;
use PayPal\Api\ItemList;
use PayPal\Test\Constants;
/**
* Class ItemList
*
* @package PayPal\Test\Api
*/
class ItemListTest extends \PHPUnit_Framework_TestCase
{
/** @var ItemList */
private $items;
private static $name = "item name";
private static $price = "1.12";
private static $quantity = "10";
private static $sku = "AXVTY123";
private static $currency = "USD";
public static function createItemList()
/**
* Gets Json String of Object ItemList
* @return string
*/
public static function getJson()
{
/** @var Item $item */
$item = ItemTest::createItem();
$itemList = new ItemList();
$itemList->setItems(array($item));
$itemList->setShippingAddress(ShippingAddressTest::getObject());
return $itemList;
return '{"items":' .ItemTest::getJson() . ',"shipping_address":' .ShippingAddressTest::getJson() . ',"shipping_method":"TestSample"}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return ItemList
*/
public static function getObject()
{
$this->items = self::createItemList();
return new ItemList(self::getJson());
}
public function testGetterSetters()
/**
* Tests for Serialization and Deserialization Issues
* @return ItemList
*/
public function testSerializationDeserialization()
{
$items = $this->items->getItems();
$this->assertEquals(ItemTest::createItem(), $items[0]);
$this->assertEquals(ShippingAddressTest::getObject(), $this->items->getShippingAddress());
$obj = new ItemList(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getItems());
$this->assertNotNull($obj->getShippingAddress());
$this->assertNotNull($obj->getShippingMethod());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param ItemList $obj
*/
public function testGetters($obj)
{
$itemList = new ItemList();
$itemList->fromJson($this->items->toJSON());
$this->assertEquals($itemList, $this->items);
$this->assertEquals($obj->getItems(), ItemTest::getObject());
$this->assertEquals($obj->getShippingAddress(), ShippingAddressTest::getObject());
$this->assertEquals($obj->getShippingMethod(), "TestSample");
}
public function testAddItemMethod()
{
$item2 = ItemTest::createItem();
$item2->setName("Item2");
$this->items->addItem($item2);
$found = false;
foreach ($this->items->getItems() as $item) {
if ($item->getName() == $item2->getName()) {
$found = true;
}
}
$this->assertTrue($found);
}
public function testRemoveItemMethod()
{
$itemList = new ItemList();
$item1 = ItemTest::createItem();
$item1->setName("Name1");
$item2 = ItemTest::createItem();
$itemList->addItem($item1);
$itemList->addItem($item2);
$itemList->removeItem($item2);
$this->assertEquals(sizeof($itemList->getItems()), 1);
$remainingElements = $itemList->getItems();
$this->assertEquals($remainingElements[0]->getName(), "Name1");
}
}

View File

@@ -1,52 +1,96 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Converter\FormatConverter;
use PayPal\Validation\NumericValidator;
use PayPal\Api\Item;
use PayPal\Test\Constants;
/**
* Class Item
*
* @package PayPal\Test\Api
*/
class ItemTest extends \PHPUnit_Framework_TestCase
{
private $item;
public static $name = "item name";
public static $price = "1.12";
public static $quantity = "10";
public static $sku = "AXVTY123";
public static $currency = "USD";
public static function createItem()
/**
* Gets Json String of Object Item
* @return string
*/
public static function getJson()
{
$item = new Item();
$item->setName(self::$name);
$item->setPrice(self::$price);
$item->setQuantity(self::$quantity);
$item->setSku(self::$sku);
$item->setCurrency(self::$currency);
return $item;
return '{"quantity":"TestSample","name":"TestSample","description":"TestSample","price":"12.34","tax":"12.34","currency":"TestSample","sku":"TestSample","url":"http://www.google.com","category":"TestSample","weight":' .MeasurementTest::getJson() . ',"length":' .MeasurementTest::getJson() . ',"height":' .MeasurementTest::getJson() . ',"width":' .MeasurementTest::getJson() . ',"supplementary_data":' .NameValuePairTest::getJson() . ',"postback_data":' .NameValuePairTest::getJson() . '}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Item
*/
public static function getObject()
{
$this->item = ItemTest::createItem();
return new Item(self::getJson());
}
public function testGetterSetters()
/**
* Tests for Serialization and Deserialization Issues
* @return Item
*/
public function testSerializationDeserialization()
{
$this->assertEquals(self::$name, $this->item->getName());
$this->assertEquals(self::$price, $this->item->getPrice());
$this->assertEquals(self::$sku, $this->item->getSku());
$this->assertEquals(self::$quantity, $this->item->getQuantity());
$this->assertEquals(self::$currency, $this->item->getCurrency());
$obj = new Item(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getQuantity());
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getDescription());
$this->assertNotNull($obj->getPrice());
$this->assertNotNull($obj->getTax());
$this->assertNotNull($obj->getCurrency());
$this->assertNotNull($obj->getSku());
$this->assertNotNull($obj->getUrl());
$this->assertNotNull($obj->getCategory());
$this->assertNotNull($obj->getWeight());
$this->assertNotNull($obj->getLength());
$this->assertNotNull($obj->getHeight());
$this->assertNotNull($obj->getWidth());
$this->assertNotNull($obj->getSupplementaryData());
$this->assertNotNull($obj->getPostbackData());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Item $obj
*/
public function testGetters($obj)
{
$item = new Item();
$item->fromJson($this->item->toJSON());
$this->assertEquals($obj->getQuantity(), "TestSample");
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getDescription(), "TestSample");
$this->assertEquals($obj->getPrice(), "12.34");
$this->assertEquals($obj->getTax(), "12.34");
$this->assertEquals($obj->getCurrency(), "TestSample");
$this->assertEquals($obj->getSku(), "TestSample");
$this->assertEquals($obj->getUrl(), "http://www.google.com");
$this->assertEquals($obj->getCategory(), "TestSample");
$this->assertEquals($obj->getWeight(), MeasurementTest::getObject());
$this->assertEquals($obj->getLength(), MeasurementTest::getObject());
$this->assertEquals($obj->getHeight(), MeasurementTest::getObject());
$this->assertEquals($obj->getWidth(), MeasurementTest::getObject());
$this->assertEquals($obj->getSupplementaryData(), NameValuePairTest::getObject());
$this->assertEquals($obj->getPostbackData(), NameValuePairTest::getObject());
}
$this->assertEquals($item, $this->item);
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Url is not a fully qualified URL
*/
public function testUrlValidationForUrl()
{
$obj = new Item();
$obj->setUrl(null);
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\Measurement;
/**
* Class Measurement
*
* @package PayPal\Test\Api
*/
class MeasurementTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Measurement
* @return string
*/
public static function getJson()
{
return '{"value":"TestSample","unit":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return Measurement
*/
public static function getObject()
{
return new Measurement(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Measurement
*/
public function testSerializationDeserialization()
{
$obj = new Measurement(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getValue());
$this->assertNotNull($obj->getUnit());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Measurement $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getValue(), "TestSample");
$this->assertEquals($obj->getUnit(), "TestSample");
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\NameValuePair;
/**
* Class NameValuePair
*
* @package PayPal\Test\Api
*/
class NameValuePairTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object NameValuePair
* @return string
*/
public static function getJson()
{
return '{"name":"TestSample","value":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return NameValuePair
*/
public static function getObject()
{
return new NameValuePair(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return NameValuePair
*/
public function testSerializationDeserialization()
{
$obj = new NameValuePair(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getValue());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param NameValuePair $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getValue(), "TestSample");
}
}

View File

@@ -1,59 +1,178 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\Capture;
use PayPal\Api\Authorization;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\Order;
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Links;
use PayPal\Test\Constants;
/**
* Class Order
*
* @package PayPal\Test\Api
*/
class OrderTest extends \PHPUnit_Framework_TestCase
{
/** @var Order */
private $order;
public static $id = 'O-0AA8876533760860M';
public static $createTime = '2014-08-25T19:24:04Z';
public static $updateTime = '2014-08-25T19:24:51Z';
public static $state = 'pending';
public static $parentPayment = 'PAY-0AL32935UM2331537KP5Y2VA';
public static $reasonCode = 'order';
public static function createOrder()
/**
* Gets Json String of Object Order
* @return string
*/
public static function getJson()
{
$order = new Order();
$order->setId(self::$id);
$order->setCreateTime(self::$createTime);
$order->setUpdateTime(self::$updateTime);
$order->setState(self::$state);
$order->setAmount(AmountTest::createAmount());
return $order;
return '{"id":"TestSample","purchase_unit_reference_id":"TestSample","amount":' .AmountTest::getJson() . ',"payment_mode":"TestSample","state":"TestSample","reason_code":"TestSample","pending_reason":"TestSample","protection-eligibility":"TestSample","protection-eligibility_type":"TestSample","parent_payment":"TestSample","fmf_details":' .FmfDetailsTest::getJson() . ',"create_time":"TestSample","update_time":"TestSample","links":' .LinksTest::getJson() . '}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Order
*/
public static function getObject()
{
$this->order = self::createOrder();
return new Order(self::getJson());
}
public function testGetterSetter()
{
$this->assertEquals(self::$id, $this->order->getId());
$this->assertEquals(self::$createTime, $this->order->getCreateTime());
$this->assertEquals(self::$updateTime, $this->order->getUpdateTime());
$this->assertEquals(self::$state, $this->order->getState());
$this->assertEquals(AmountTest::$currency, $this->order->getAmount()->getCurrency());
/**
* Tests for Serialization and Deserialization Issues
* @return Order
*/
public function testSerializationDeserialization()
{
$obj = new Order(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getPurchaseUnitReferenceId());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getPaymentMode());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getReasonCode());
$this->assertNotNull($obj->getPendingReason());
$this->assertNotNull($obj->getProtectionEligibility());
$this->assertNotNull($obj->getProtectionEligibilityType());
$this->assertNotNull($obj->getParentPayment());
$this->assertNotNull($obj->getFmfDetails());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Order $obj
*/
public function testGetters($obj)
{
$o1 = $this->order;
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getPurchaseUnitReferenceId(), "TestSample");
$this->assertEquals($obj->getAmount(), AmountTest::getObject());
$this->assertEquals($obj->getPaymentMode(), "TestSample");
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getReasonCode(), "TestSample");
$this->assertEquals($obj->getPendingReason(), "TestSample");
$this->assertEquals($obj->getProtectionEligibility(), "TestSample");
$this->assertEquals($obj->getProtectionEligibilityType(), "TestSample");
$this->assertEquals($obj->getParentPayment(), "TestSample");
$this->assertEquals($obj->getFmfDetails(), FmfDetailsTest::getObject());
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
$o2 = new Order();
$o2->fromJson($o1->toJson());
$this->assertEquals($o1, $o2);
/**
* @dataProvider mockProvider
* @param Order $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
OrderTest::getJson()
));
$result = $obj->get("orderId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Order $obj
*/
public function testCapture($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
CaptureTest::getJson()
));
$capture = CaptureTest::getObject();
$result = $obj->capture($capture, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Order $obj
*/
public function testVoid($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$result = $obj->void($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Order $obj
*/
public function testAuthorize($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
AuthorizationTest::getJson()
));
$authorization = new Authorization();
$result = $obj->authorize($authorization, $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

@@ -2,48 +2,56 @@
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\Payee;
use PayPal\Test\Constants;
/**
* Class Payee
*
* @package PayPal\Test\Api
*/
class PayeeTest extends \PHPUnit_Framework_TestCase
{
private $payee;
public static $email = "test@paypal.com";
public static $merchant_id = "1XY12121";
public static $phone = "+14081234566";
public static function createPayee()
/**
* Gets Json String of Object Payee
* @return string
*/
public static function getJson()
{
$payee = new Payee();
$payee->setEmail(self::$email);
$payee->setMerchantId(self::$merchant_id);
$payee->setPhone(self::$phone);
return $payee;
return '{"email":"TestSample","merchant_id":"TestSample"}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Payee
*/
public static function getObject()
{
$this->payee = self::createPayee();
return new Payee(self::getJson());
}
public function testGetterSetter()
/**
* Tests for Serialization and Deserialization Issues
* @return Payee
*/
public function testSerializationDeserialization()
{
$this->assertEquals(self::$email, $this->payee->getEmail());
$this->assertEquals(self::$merchant_id, $this->payee->getMerchantId());
$this->assertEquals(self::$phone, $this->payee->getPhone());
$obj = new Payee(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getEmail());
$this->assertNotNull($obj->getMerchantId());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Payee $obj
*/
public function testGetters($obj)
{
$p1 = $this->payee;
$p2 = new Payee();
$p2->fromJson($p1->toJson());
$this->assertEquals($p1, $p2);
$this->assertEquals($obj->getEmail(), "TestSample");
$this->assertEquals($obj->getMerchantId(), "TestSample");
}
}
}

View File

@@ -18,7 +18,7 @@ class PayerInfoTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"email":"TestSample","external_remember_me_id":"TestSample","buyer_account_number":"TestSample","first_name":"TestSample","last_name":"TestSample","payer_id":"TestSample","phone":"TestSample","phone_type":"TestSample","birth_date":"TestSample","tax_id":"TestSample","tax_id_type":"TestSample","billing_address":' .AddressTest::getJson() . ',"shipping_address":' .ShippingAddressTest::getJson() . '}';
return '{"email":"TestSample","external_remember_me_id":"TestSample","buyer_account_number":"TestSample","salutation":"TestSample","first_name":"TestSample","middle_name":"TestSample","last_name":"TestSample","suffix":"TestSample","payer_id":"TestSample","phone":"TestSample","phone_type":"TestSample","birth_date":"TestSample","tax_id":"TestSample","tax_id_type":"TestSample","country_code":"TestSample","billing_address":' .AddressTest::getJson() . ',"shipping_address":' .ShippingAddressTest::getJson() . '}';
}
/**
@@ -42,14 +42,18 @@ class PayerInfoTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getEmail());
$this->assertNotNull($obj->getExternalRememberMeId());
$this->assertNotNull($obj->getBuyerAccountNumber());
$this->assertNotNull($obj->getSalutation());
$this->assertNotNull($obj->getFirstName());
$this->assertNotNull($obj->getMiddleName());
$this->assertNotNull($obj->getLastName());
$this->assertNotNull($obj->getSuffix());
$this->assertNotNull($obj->getPayerId());
$this->assertNotNull($obj->getPhone());
$this->assertNotNull($obj->getPhoneType());
$this->assertNotNull($obj->getBirthDate());
$this->assertNotNull($obj->getTaxId());
$this->assertNotNull($obj->getTaxIdType());
$this->assertNotNull($obj->getCountryCode());
$this->assertNotNull($obj->getBillingAddress());
$this->assertNotNull($obj->getShippingAddress());
$this->assertEquals(self::getJson(), $obj->toJson());
@@ -65,14 +69,18 @@ class PayerInfoTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getEmail(), "TestSample");
$this->assertEquals($obj->getExternalRememberMeId(), "TestSample");
$this->assertEquals($obj->getBuyerAccountNumber(), "TestSample");
$this->assertEquals($obj->getSalutation(), "TestSample");
$this->assertEquals($obj->getFirstName(), "TestSample");
$this->assertEquals($obj->getMiddleName(), "TestSample");
$this->assertEquals($obj->getLastName(), "TestSample");
$this->assertEquals($obj->getSuffix(), "TestSample");
$this->assertEquals($obj->getPayerId(), "TestSample");
$this->assertEquals($obj->getPhone(), "TestSample");
$this->assertEquals($obj->getPhoneType(), "TestSample");
$this->assertEquals($obj->getBirthDate(), "TestSample");
$this->assertEquals($obj->getTaxId(), "TestSample");
$this->assertEquals($obj->getTaxIdType(), "TestSample");
$this->assertEquals($obj->getCountryCode(), "TestSample");
$this->assertEquals($obj->getBillingAddress(), AddressTest::getObject());
$this->assertEquals($obj->getShippingAddress(), ShippingAddressTest::getObject());
}

View File

@@ -18,7 +18,7 @@ class PayerTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"payment_method":"TestSample","status":"TestSample","funding_instruments":' .FundingInstrumentTest::getJson() . ',"funding_option_id":"TestSample","payer_info":' .PayerInfoTest::getJson() . '}';
return '{"payment_method":"TestSample","status":"TestSample","account_type":"TestSample","account_age":"TestSample","funding_instruments":' .FundingInstrumentTest::getJson() . ',"funding_option_id":"TestSample","funding_option":' .FundingOptionTest::getJson() . ',"related_funding_option":' .FundingOptionTest::getJson() . ',"payer_info":' .PayerInfoTest::getJson() . '}';
}
/**
@@ -41,8 +41,12 @@ class PayerTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj);
$this->assertNotNull($obj->getPaymentMethod());
$this->assertNotNull($obj->getStatus());
$this->assertNotNull($obj->getAccountType());
$this->assertNotNull($obj->getAccountAge());
$this->assertNotNull($obj->getFundingInstruments());
$this->assertNotNull($obj->getFundingOptionId());
$this->assertNotNull($obj->getFundingOption());
$this->assertNotNull($obj->getRelatedFundingOption());
$this->assertNotNull($obj->getPayerInfo());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
@@ -56,8 +60,12 @@ class PayerTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals($obj->getPaymentMethod(), "TestSample");
$this->assertEquals($obj->getStatus(), "TestSample");
$this->assertEquals($obj->getAccountType(), "TestSample");
$this->assertEquals($obj->getAccountAge(), "TestSample");
$this->assertEquals($obj->getFundingInstruments(), FundingInstrumentTest::getObject());
$this->assertEquals($obj->getFundingOptionId(), "TestSample");
$this->assertEquals($obj->getFundingOption(), FundingOptionTest::getObject());
$this->assertEquals($obj->getRelatedFundingOption(), FundingOptionTest::getObject());
$this->assertEquals($obj->getPayerInfo(), PayerInfoTest::getObject());
}

View File

@@ -18,7 +18,7 @@ class PaymentCardTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"id":"TestSample","number":"TestSample","type":"TestSample","expire_month":123,"expire_year":123,"start_month":123,"start_year":123,"cvv2":123,"first_name":"TestSample","last_name":"TestSample","billing_address":' .AddressTest::getJson() . ',"external_customer_id":"TestSample","status":"TestSample","valid_until":"TestSample","links":' .LinksTest::getJson() . '}';
return '{"id":"TestSample","number":"TestSample","type":"TestSample","expire_month":123,"expire_year":123,"start_month":"TestSample","start_year":"TestSample","cvv2":"TestSample","first_name":"TestSample","last_name":"TestSample","billing_country":"TestSample","billing_address":' .AddressTest::getJson() . ',"external_customer_id":"TestSample","status":"TestSample","valid_until":"TestSample","links":' .LinksTest::getJson() . '}';
}
/**
@@ -49,6 +49,7 @@ class PaymentCardTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getCvv2());
$this->assertNotNull($obj->getFirstName());
$this->assertNotNull($obj->getLastName());
$this->assertNotNull($obj->getBillingCountry());
$this->assertNotNull($obj->getBillingAddress());
$this->assertNotNull($obj->getExternalCustomerId());
$this->assertNotNull($obj->getStatus());
@@ -69,11 +70,12 @@ class PaymentCardTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getType(), "TestSample");
$this->assertEquals($obj->getExpireMonth(), 123);
$this->assertEquals($obj->getExpireYear(), 123);
$this->assertEquals($obj->getStartMonth(), 123);
$this->assertEquals($obj->getStartYear(), 123);
$this->assertEquals($obj->getCvv2(), 123);
$this->assertEquals($obj->getStartMonth(), "TestSample");
$this->assertEquals($obj->getStartYear(), "TestSample");
$this->assertEquals($obj->getCvv2(), "TestSample");
$this->assertEquals($obj->getFirstName(), "TestSample");
$this->assertEquals($obj->getLastName(), "TestSample");
$this->assertEquals($obj->getBillingCountry(), "TestSample");
$this->assertEquals($obj->getBillingAddress(), AddressTest::getObject());
$this->assertEquals($obj->getExternalCustomerId(), "TestSample");
$this->assertEquals($obj->getStatus(), "TestSample");

View File

@@ -0,0 +1,57 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\PaymentExecution;
/**
* Class PaymentExecution
*
* @package PayPal\Test\Api
*/
class PaymentExecutionTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object PaymentExecution
* @return string
*/
public static function getJson()
{
return '{"payer_id":"TestSample","transactions":' .TransactionTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return PaymentExecution
*/
public static function getObject()
{
return new PaymentExecution(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return PaymentExecution
*/
public function testSerializationDeserialization()
{
$obj = new PaymentExecution(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getPayerId());
$this->assertNotNull($obj->getTransactions());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param PaymentExecution $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getPayerId(), "TestSample");
$this->assertEquals($obj->getTransactions(), TransactionTest::getObject());
}
}

View File

@@ -2,45 +2,58 @@
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\PaymentHistory;
use PayPal\Test\Constants;
/**
* Class PaymentHistory
*
* @package PayPal\Test\Api
*/
class PaymentHistoryTest extends \PHPUnit_Framework_TestCase
{
/** @var PaymentHistory */
private $history;
public static $count = 10;
public static $nextId = "11";
public static function createPaymentHistory()
/**
* Gets Json String of Object PaymentHistory
* @return string
*/
public static function getJson()
{
$history = new PaymentHistory();
$history->setCount(self::$count);
$history->setNextId(self::$nextId);
$history->setPayments(array(PaymentTest::createPayment()));
return $history;
return '{"payments":' .PaymentTest::getJson() . ',"count":123,"next_id":"TestSample"}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return PaymentHistory
*/
public static function getObject()
{
$this->history = PaymentHistoryTest::createPaymentHistory();
return new PaymentHistory(self::getJson());
}
public function testGetterSetters()
{
$this->assertEquals(self::$count, $this->history->getCount());
$this->assertEquals(self::$nextId, $this->history->getNextId());
/**
* Tests for Serialization and Deserialization Issues
* @return PaymentHistory
*/
public function testSerializationDeserialization()
{
$obj = new PaymentHistory(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getPayments());
$this->assertNotNull($obj->getCount());
$this->assertNotNull($obj->getNextId());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param PaymentHistory $obj
*/
public function testGetters($obj)
{
$history = new PaymentHistory();
$history->fromJson($this->history->toJSON());
$this->assertEquals($history, $this->history);
$this->assertEquals($obj->getPayments(), PaymentTest::getObject());
$this->assertEquals($obj->getCount(), 123);
$this->assertEquals($obj->getNextId(), "TestSample");
}
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\PaymentInstruction;
/**
* Class PaymentInstruction
*
* @package PayPal\Test\Api
*/
class PaymentInstructionTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object PaymentInstruction
* @return string
*/
public static function getJson()
{
return '{"reference_number":"TestSample","instruction_type":"TestSample","recipient_banking_instruction":' .RecipientBankingInstructionTest::getJson() . ',"amount":' .CurrencyTest::getJson() . ',"payment_due_date":"TestSample","note":"TestSample","links":' .LinksTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return PaymentInstruction
*/
public static function getObject()
{
return new PaymentInstruction(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return PaymentInstruction
*/
public function testSerializationDeserialization()
{
$obj = new PaymentInstruction(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getReferenceNumber());
$this->assertNotNull($obj->getInstructionType());
$this->assertNotNull($obj->getRecipientBankingInstruction());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getPaymentDueDate());
$this->assertNotNull($obj->getNote());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param PaymentInstruction $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getReferenceNumber(), "TestSample");
$this->assertEquals($obj->getInstructionType(), "TestSample");
$this->assertEquals($obj->getRecipientBankingInstruction(), RecipientBankingInstructionTest::getObject());
$this->assertEquals($obj->getAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getPaymentDueDate(), "TestSample");
$this->assertEquals($obj->getNote(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
/**
* @dataProvider mockProvider
* @param PaymentInstruction $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
PaymentInstructionTest::getJson()
));
$result = $obj->get("paymentId", $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

@@ -0,0 +1,55 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\PaymentOptions;
/**
* Class PaymentOptions
*
* @package PayPal\Test\Api
*/
class PaymentOptionsTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object PaymentOptions
* @return string
*/
public static function getJson()
{
return '{"allowed_payment_method":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return PaymentOptions
*/
public static function getObject()
{
return new PaymentOptions(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return PaymentOptions
*/
public function testSerializationDeserialization()
{
$obj = new PaymentOptions(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getAllowedPaymentMethod());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param PaymentOptions $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getAllowedPaymentMethod(), "TestSample");
}
}

View File

@@ -1,162 +1,197 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Address;
use PayPal\Api\Amount;
use PayPal\Api\CreditCard;
use PayPal\Api\Payer;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\object;
use PayPal\Api\PaymentHistory;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\Payment;
use PayPal\Api\FundingInstrument;
use PayPal\Api\Transaction;
use PayPal\Test\Constants;
/**
* Class Payment
*
* @package PayPal\Test\Api
*/
class PaymentTest extends \PHPUnit_Framework_TestCase
{
private $payments;
public static function createPayment()
/**
* Gets Json String of Object Payment
* @return string
*/
public static function getJson()
{
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("http://localhost/return");
$redirectUrls->setCancelUrl("http://localhost/cancel");
$payment = new Payment();
$payment->setIntent("sale");
$payment->setRedirectUrls($redirectUrls);
$payment->setPayer(PayerTest::getObject());
$payment->setTransactions(array(TransactionTest::createTransaction()));
return $payment;
}
public static function createNewPayment()
{
$funding = FundingInstrumentTest::getObject();
$funding->credit_card_token = null;
$payer = new Payer();
$payer->setPaymentMethod("credit_card");
$payer->setFundingInstruments(array($funding));
$transaction = new Transaction();
$transaction->setAmount(AmountTest::createAmount());
$transaction->setDescription("This is the payment description.");
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("http://localhost/return");
$redirectUrls->setCancelUrl("http://localhost/cancel");
$payment = new Payment();
$payment->setIntent("sale");
$payment->setRedirectUrls($redirectUrls);
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
return $payment;
}
public function setup()
{
$this->payments['full'] = self::createPayment();
$this->payments['new'] = self::createNewPayment();
}
public function testSerializeDeserialize()
{
$p2 = new Payment();
$p2->fromJson($this->payments['full']->toJSON());
$this->assertEquals($p2, $this->payments['full']);
return '{"id":"TestSample","intent":"TestSample","payer":' .PayerTest::getJson() . ',"payee":' .PayeeTest::getJson() . ',"cart":"TestSample","transactions":' .TransactionTest::getJson() . ',"failed_transactions":' .ErrorTest::getJson() . ',"payment_instruction":' .PaymentInstructionTest::getJson() . ',"state":"TestSample","experience_profile_id":"TestSample","redirect_urls":' .RedirectUrlsTest::getJson() . ',"create_time":"TestSample","update_time":"TestSample","links":' .LinksTest::getJson() . '}';
}
/**
* @group integration
*
* Tests Additional_fields, shipping_discount and insurance information.
* Additional Information: https://developer.paypal.com/docs/integration/direct/explore-payment-capabilities/
* Gets Object Instance with Json data filled in
* @return Payment
*/
public function testECParameters()
public static function getObject()
{
$json = '{
"intent": "sale",
"redirect_urls": {
"return_url": "http://www.return.com",
"cancel_url": "http://www.cancel.com"
},
"payer": {
"payment_method": "paypal",
"payer_info": {
"tax_id_type": "BR_CPF",
"tax_id": "Fh618775690"
}
},
"transactions": [
{
"amount": {
"total": "34.07",
"currency": "USD",
"details": {
"subtotal": "30.00",
"tax": "0.07",
"shipping": "1.00",
"handling_fee": "1.00",
"shipping_discount": "1.00",
"insurance": "1.00"
}
},
"description": "This is the payment transaction description.",
"custom": "EBAY_EMS_90048630024435",
"invoice_number": "48787589677",
"payment_options": {
"allowed_payment_method": "INSTANT_FUNDING_SOURCE"
},
"soft_descriptor": "ECHI5786786",
"item_list": {
"items": [
{
"name": "bowling",
"description": "Bowling Team Shirt",
"quantity": "5",
"price": "3",
"tax": "0.01",
"sku": "1",
"currency": "USD"
},
{
"name": "mesh",
"description": "80s Mesh Sleeveless Shirt",
"quantity": "1",
"price": "15",
"tax": "0.02",
"sku": "product34",
"currency": "USD"
}
],
"shipping_address": {
"recipient_name": "Betsy Buyer",
"line1": "111 First Street",
"city": "Saratoga",
"country_code": "US",
"postal_code": "95070",
"state": "CA"
}
}
}
]
}';
$payment = new Payment();
$payment->fromJson($json);
return new Payment(self::getJson());
}
$payment->create();
$result = Payment::get($payment->getId());
$transactions = $result->getTransactions();
$transaction = $transactions[0];
$this->assertEquals($transaction->getAmount()->getDetails()->getShippingDiscount(), '1.00');
$this->assertEquals($transaction->getAmount()->getDetails()->getInsurance(), '1.00');
$this->assertEquals($transaction->getAmount()->getDetails()->getHandlingFee(), '1.00');
/**
* Tests for Serialization and Deserialization Issues
* @return Payment
*/
public function testSerializationDeserialization()
{
$obj = new Payment(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getIntent());
$this->assertNotNull($obj->getPayer());
$this->assertNotNull($obj->getPayee());
$this->assertNotNull($obj->getCart());
$this->assertNotNull($obj->getTransactions());
$this->assertNotNull($obj->getFailedTransactions());
$this->assertNotNull($obj->getPaymentInstruction());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getExperienceProfileId());
$this->assertNotNull($obj->getRedirectUrls());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Payment $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getIntent(), "TestSample");
$this->assertEquals($obj->getPayer(), PayerTest::getObject());
$this->assertEquals($obj->getPayee(), PayeeTest::getObject());
$this->assertEquals($obj->getCart(), "TestSample");
$this->assertEquals($obj->getTransactions(), TransactionTest::getObject());
$this->assertEquals($obj->getFailedTransactions(), ErrorTest::getObject());
$this->assertEquals($obj->getPaymentInstruction(), PaymentInstructionTest::getObject());
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getExperienceProfileId(), "TestSample");
$this->assertEquals($obj->getRedirectUrls(), RedirectUrlsTest::getObject());
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
/**
* @dataProvider mockProvider
* @param Payment $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 Payment $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
PaymentTest::getJson()
));
$result = $obj->get("paymentId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Payment $obj
*/
public function testUpdate($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
true
));
$patchRequest = PatchRequestTest::getObject();
$result = $obj->update($patchRequest, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Payment $obj
*/
public function testExecute($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
));
$paymentExecution = PaymentExecutionTest::getObject();
$result = $obj->execute($paymentExecution, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Payment $obj
*/
public function testList($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
PaymentHistoryTest::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

@@ -18,7 +18,7 @@ class PhoneTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"country_code":"TestSample","national_number":"TestSample"}';
return '{"country_code":"TestSample","national_number":"TestSample","extension":"TestSample"}';
}
/**
@@ -41,6 +41,7 @@ class PhoneTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj);
$this->assertNotNull($obj->getCountryCode());
$this->assertNotNull($obj->getNationalNumber());
$this->assertNotNull($obj->getExtension());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -53,6 +54,7 @@ class PhoneTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals($obj->getCountryCode(), "TestSample");
$this->assertEquals($obj->getNationalNumber(), "TestSample");
$this->assertEquals($obj->getExtension(), "TestSample");
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\RecipientBankingInstruction;
/**
* Class RecipientBankingInstruction
*
* @package PayPal\Test\Api
*/
class RecipientBankingInstructionTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object RecipientBankingInstruction
* @return string
*/
public static function getJson()
{
return '{"bank_name":"TestSample","account_holder_name":"TestSample","account_number":"TestSample","routing_number":"TestSample","international_bank_account_number":"TestSample","bank_identifier_code":"TestSample"}';
}
/**
* Gets Object Instance with Json data filled in
* @return RecipientBankingInstruction
*/
public static function getObject()
{
return new RecipientBankingInstruction(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return RecipientBankingInstruction
*/
public function testSerializationDeserialization()
{
$obj = new RecipientBankingInstruction(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getBankName());
$this->assertNotNull($obj->getAccountHolderName());
$this->assertNotNull($obj->getAccountNumber());
$this->assertNotNull($obj->getRoutingNumber());
$this->assertNotNull($obj->getInternationalBankAccountNumber());
$this->assertNotNull($obj->getBankIdentifierCode());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param RecipientBankingInstruction $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getBankName(), "TestSample");
$this->assertEquals($obj->getAccountHolderName(), "TestSample");
$this->assertEquals($obj->getAccountNumber(), "TestSample");
$this->assertEquals($obj->getRoutingNumber(), "TestSample");
$this->assertEquals($obj->getInternationalBankAccountNumber(), "TestSample");
$this->assertEquals($obj->getBankIdentifierCode(), "TestSample");
}
}

View File

@@ -1,47 +1,57 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\RedirectUrls;
/**
* Class RedirectUrls
*
* @package PayPal\Test\Api
*/
class RedirectUrlsTest extends \PHPUnit_Framework_TestCase
{
public function validRedirectUrlsProvider()
/**
* Gets Json String of Object RedirectUrls
* @return string
*/
public static function getJson()
{
return array(
array('https://devtools-paypal.com/guide/pay_paypal/php?success=true', 'https://devtools-paypal.com/guide/pay_paypal/php?cancel=true')
);
}
public function invalidRedirectUrlsProvider()
{
return array(
array('devtools-paypal.com/guide/pay_paypal/php?success=true', 'devtools-paypal.com/guide/pay_paypal/php?cancel=true')
);
return '{"return_url":"http://www.google.com","cancel_url":"http://www.google.com"}';
}
/**
* @dataProvider validRedirectUrlsProvider
* Gets Object Instance with Json data filled in
* @return RedirectUrls
*/
public function testValidRedirectUrls($return_url, $cancel_url)
public static function getObject()
{
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl($return_url);
$redirectUrls->setCancelUrl($cancel_url);
return new RedirectUrls(self::getJson());
}
$this->assertEquals($return_url, $redirectUrls->getReturnUrl());
$this->assertEquals($cancel_url, $redirectUrls->getCancelUrl());
/**
* Tests for Serialization and Deserialization Issues
* @return RedirectUrls
*/
public function testSerializationDeserialization()
{
$obj = new RedirectUrls(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getReturnUrl());
$this->assertNotNull($obj->getCancelUrl());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @dataProvider invalidRedirectUrlsProvider
* @depends testSerializationDeserialization
* @param RedirectUrls $obj
*/
public function testInvalidRedirectUrls($return_url, $cancel_url)
public function testGetters($obj)
{
$redirectUrls = new RedirectUrls();
$this->setExpectedException('\InvalidArgumentException');
$redirectUrls->setReturnUrl($return_url);
$redirectUrls->setCancelUrl($cancel_url);
$this->assertEquals($obj->getReturnUrl(), "http://www.google.com");
$this->assertEquals($obj->getCancelUrl(), "http://www.google.com");
}
}
}

View File

@@ -1,59 +1,110 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\Refund;
use PayPal\Test\Constants;
/**
* Class Refund
*
* @package PayPal\Test\Api
*/
class RefundTest extends \PHPUnit_Framework_TestCase
{
private $refund;
public static $captureId = "CAP-123";
public static $createTime = "2013-02-28T00:00:00Z";
public static $id = "R-5678";
public static $parentPayment = "PAY-123";
public static function createRefund()
/**
* Gets Json String of Object Refund
* @return string
*/
public static function getJson()
{
$refund = new Refund();
$refund->setCreateTime(self::$createTime);
$refund->setAmount(AmountTest::createAmount());
$refund->setCaptureId(self::$captureId);
$refund->setId(self::$id);
$refund->setLinks(array(LinksTest::getObject()));
$refund->setParentPayment(self::$parentPayment);
return $refund;
return '{"id":"TestSample","amount":' .AmountTest::getJson() . ',"state":"TestSample","reason":"TestSample","sale_id":"TestSample","capture_id":"TestSample","parent_payment":"TestSample","description":"TestSample","create_time":"TestSample","update_time":"TestSample","links":' .LinksTest::getJson() . '}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Refund
*/
public static function getObject()
{
$this->refund = self::createRefund();
return new Refund(self::getJson());
}
public function testGetterSetter()
/**
* Tests for Serialization and Deserialization Issues
* @return Refund
*/
public function testSerializationDeserialization()
{
$this->assertEquals(self::$captureId, $this->refund->getCaptureId());
$this->assertEquals(self::$createTime, $this->refund->getCreateTime());
$this->assertEquals(self::$id, $this->refund->getId());
$this->assertEquals(self::$parentPayment, $this->refund->getParentPayment());
$this->assertEquals(AmountTest::$currency, $this->refund->getAmount()->getCurrency());
$links = $this->refund->getLinks();
$obj = new Refund(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getReason());
$this->assertNotNull($obj->getSaleId());
$this->assertNotNull($obj->getCaptureId());
$this->assertNotNull($obj->getParentPayment());
$this->assertNotNull($obj->getDescription());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Refund $obj
*/
public function testGetters($obj)
{
$r1 = $this->refund;
$r2 = new Refund();
$r2->fromJson($r1->toJson());
$this->assertEquals($r1, $r2);
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getAmount(), AmountTest::getObject());
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getReason(), "TestSample");
$this->assertEquals($obj->getSaleId(), "TestSample");
$this->assertEquals($obj->getCaptureId(), "TestSample");
$this->assertEquals($obj->getParentPayment(), "TestSample");
$this->assertEquals($obj->getDescription(), "TestSample");
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
public function testOperations()
/**
* @dataProvider mockProvider
* @param Refund $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
RefundTest::getJson()
));
$result = $obj->get("refundId", $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

@@ -1,42 +1,54 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\RelatedResources;
use PayPal\Test\Constants;
/**
* Class RelatedResources
*
* @package PayPal\Test\Api
*/
class RelatedResourcesTest extends \PHPUnit_Framework_TestCase
{
private $RelatedResources;
public static function createRelatedResources()
/**
* Gets Json String of Object RelatedResources
* @return string
*/
public static function getJson()
{
$relatedResources = new RelatedResources();
$relatedResources->setAuthorization(AuthorizationTest::createAuthorization());
$relatedResources->setCapture(CaptureTest::createCapture());
$relatedResources->setOrder(OrderTest::createOrder());
return $relatedResources;
return '{}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return RelatedResources
*/
public static function getObject()
{
$this->relatedResources = self::createRelatedResources();
return new RelatedResources(self::getJson());
}
public function testGetterSetter()
/**
* Tests for Serialization and Deserialization Issues
* @return RelatedResources
*/
public function testSerializationDeserialization()
{
$this->assertEquals(AuthorizationTest::$create_time, $this->relatedResources->getAuthorization()->getCreateTime());
$this->assertEquals(CaptureTest::$create_time, $this->relatedResources->getCapture()->getCreateTime());
$this->assertEquals(OrderTest::$id, $this->relatedResources->getOrder()->getId());
$obj = new RelatedResources(self::getJson());
$this->assertNotNull($obj);
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param RelatedResources $obj
*/
public function testGetters($obj)
{
$s1 = $this->relatedResources;
$s2 = new RelatedResources();
$s2->fromJson($s1->toJson());
$this->assertEquals($s1, $s2);
}
}

View File

@@ -1,63 +1,149 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Api\Currency;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\Refund;
use PayPal\Rest\ApiContext;
use PayPal\Transport\PPRestCall;
use PayPal\Api\Sale;
use PayPal\Test\Api\AmountTest;
/**
* Class Sale
*
* @package PayPal\Test\Api
*/
class SaleTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Sale
* Gets Json String of Object Sale
* @return string
*/
private $sale;
private $tFee;
public static $captureId = "CAP-123";
public static $createTime = "2013-02-28T00:00:00Z";
public static $id = "R-5678";
public static $parentPayment = "PAY-123";
public static $state = "Created";
private function createSale()
public static function getJson()
{
$sale = new Sale();
$sale->setAmount(AmountTest::createAmount());
$sale->setCreateTime(self::$createTime);
$sale->setId(self::$id);
$sale->setParentPayment(self::$parentPayment);
$sale->setState(self::$state);
$this->tFee = new Currency();
$this->tFee->setCurrency('AUD');
$this->tFee->setValue('0.10');
$sale->setTransactionFee($this->tFee);
return $sale;
return '{"id":"TestSample","purchase_unit_reference_id":"TestSample","amount":' .AmountTest::getJson() . ',"payment_mode":"TestSample","state":"TestSample","reason_code":"TestSample","protection_eligibility":"TestSample","protection_eligibility_type":"TestSample","clearing_time":"TestSample","recipient_fund_status":"TestSample","hold_reason":"TestSample","transaction_fee":' .CurrencyTest::getJson() . ',"receivable_amount":' .CurrencyTest::getJson() . ',"exchange_rate":"TestSample","fmf_details":' .FmfDetailsTest::getJson() . ',"receipt_id":"TestSample","parent_payment":"TestSample","create_time":"TestSample","update_time":"TestSample","links":' .LinksTest::getJson() . '}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Sale
*/
public static function getObject()
{
$this->sale = $this->createSale();
return new Sale(self::getJson());
}
public function testGetterSetter()
/**
* Tests for Serialization and Deserialization Issues
* @return Sale
*/
public function testSerializationDeserialization()
{
$this->assertEquals(self::$createTime, $this->sale->getCreateTime());
$this->assertEquals(self::$id, $this->sale->getId());
$this->assertEquals(self::$parentPayment, $this->sale->getParentPayment());
$this->assertEquals(self::$state, $this->sale->getState());
$this->assertEquals(AmountTest::$currency, $this->sale->getAmount()->getCurrency());
$this->assertEquals($this->tFee, $this->sale->getTransactionFee());
$obj = new Sale(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getPurchaseUnitReferenceId());
$this->assertNotNull($obj->getAmount());
$this->assertNotNull($obj->getPaymentMode());
$this->assertNotNull($obj->getState());
$this->assertNotNull($obj->getReasonCode());
$this->assertNotNull($obj->getProtectionEligibility());
$this->assertNotNull($obj->getProtectionEligibilityType());
$this->assertNotNull($obj->getClearingTime());
$this->assertNotNull($obj->getRecipientFundStatus());
$this->assertNotNull($obj->getHoldReason());
$this->assertNotNull($obj->getTransactionFee());
$this->assertNotNull($obj->getReceivableAmount());
$this->assertNotNull($obj->getExchangeRate());
$this->assertNotNull($obj->getFmfDetails());
$this->assertNotNull($obj->getReceiptId());
$this->assertNotNull($obj->getParentPayment());
$this->assertNotNull($obj->getCreateTime());
$this->assertNotNull($obj->getUpdateTime());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Sale $obj
*/
public function testGetters($obj)
{
$s1 = $this->sale;
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getPurchaseUnitReferenceId(), "TestSample");
$this->assertEquals($obj->getAmount(), AmountTest::getObject());
$this->assertEquals($obj->getPaymentMode(), "TestSample");
$this->assertEquals($obj->getState(), "TestSample");
$this->assertEquals($obj->getReasonCode(), "TestSample");
$this->assertEquals($obj->getProtectionEligibility(), "TestSample");
$this->assertEquals($obj->getProtectionEligibilityType(), "TestSample");
$this->assertEquals($obj->getClearingTime(), "TestSample");
$this->assertEquals($obj->getRecipientFundStatus(), "TestSample");
$this->assertEquals($obj->getHoldReason(), "TestSample");
$this->assertEquals($obj->getTransactionFee(), CurrencyTest::getObject());
$this->assertEquals($obj->getReceivableAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getExchangeRate(), "TestSample");
$this->assertEquals($obj->getFmfDetails(), FmfDetailsTest::getObject());
$this->assertEquals($obj->getReceiptId(), "TestSample");
$this->assertEquals($obj->getParentPayment(), "TestSample");
$this->assertEquals($obj->getCreateTime(), "TestSample");
$this->assertEquals($obj->getUpdateTime(), "TestSample");
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
$s2 = new Sale();
$s2->fromJson($s1->toJson());
/**
* @dataProvider mockProvider
* @param Sale $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$this->assertEquals($s1, $s2);
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
SaleTest::getJson()
));
$result = $obj->get("saleId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Sale $obj
*/
public function testRefund($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
RefundTest::getJson()
));
$refund = RefundTest::getObject();
$result = $obj->refund($refund, $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

@@ -2,60 +2,52 @@
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\Transaction;
/**
* Class Transaction
*
* @package PayPal\Test\Api
*/
class TransactionTest extends \PHPUnit_Framework_TestCase
{
/** @var Transaction */
private $transaction;
public static $description = "desc . . . ";
public static $invoiceNumber = "#123";
public static $custom = "custom";
public static $softDescriptor = "descriptor";
public static $total = "1.12";
public static function createTransaction()
/**
* Gets Json String of Object Transaction
* @return string
*/
public static function getJson()
{
$transaction = new Transaction();
$transaction->setAmount(AmountTest::createAmount());
$transaction->setDescription(self::$description);
$transaction->setInvoiceNumber(self::$invoiceNumber);
$transaction->setCustom(self::$custom);
$transaction->setSoftDescriptor(self::$softDescriptor);
$transaction->setItemList(ItemListTest::createItemList());
$transaction->setPayee(PayeeTest::createPayee());
$transaction->setRelatedResources(array(RelatedResourcesTest::createRelatedResources()));
return $transaction;
return '{}';
}
public function setup()
/**
* Gets Object Instance with Json data filled in
* @return Transaction
*/
public static function getObject()
{
$this->transaction = self::createTransaction();
return new Transaction(self::getJson());
}
public function testGetterSetter()
/**
* Tests for Serialization and Deserialization Issues
* @return Transaction
*/
public function testSerializationDeserialization()
{
$this->assertEquals(AmountTest::$currency, $this->transaction->getAmount()->getCurrency());
$this->assertEquals(self::$description, $this->transaction->getDescription());
$this->assertEquals(self::$invoiceNumber, $this->transaction->getInvoiceNumber());
$this->assertEquals(self::$custom, $this->transaction->getCustom());
$this->assertEquals(self::$softDescriptor, $this->transaction->getSoftDescriptor());
$items = $this->transaction->getItemList()->getItems();
$this->assertEquals(ItemTest::$quantity, $items[0]->getQuantity());
$this->assertEquals(PayeeTest::$email, $this->transaction->getPayee()->getEmail());
$resources = $this->transaction->getRelatedResources();
$this->assertEquals(AuthorizationTest::$create_time, $resources[0]->getAuthorization()->getCreateTime());
$obj = new Transaction(self::getJson());
$this->assertNotNull($obj);
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
public function testSerializeDeserialize()
/**
* @depends testSerializationDeserialization
* @param Transaction $obj
*/
public function testGetters($obj)
{
$t1 = $this->transaction;
$t2 = new Transaction();
$t2->fromJson($t1->toJson());
$this->assertEquals($t1, $t2);
}
}

View File

@@ -8,13 +8,7 @@ use PayPal\Api\Currency;
use PayPal\Api\Patch;
use PayPal\Api\PatchRequest;
use PayPal\Api\Plan;
use PayPal\Common\PayPalModel;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Api\CreateProfileResponse;
use PayPal\Test\Functional\Setup;
use PayPal\Transport\PayPalRestCall;
use PayPal\Api\WebProfile;
/**
* Class Billing Agreements
@@ -28,6 +22,8 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
public $response;
public $apiContext;
public $mockPayPalRestCall;
public function setUp()
@@ -67,7 +63,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
$agreement = new Agreement($request);
// Update the Schema to use a working Plan
$agreement->getPlan()->setId($plan->getId());
$result = $agreement->create(null, $this->mockPayPalRestCall);
$result = $agreement->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}
@@ -88,7 +84,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
$paymentToken = $result['token'];
$this->assertNotNull($paymentToken);
$this->assertNotEmpty($paymentToken);
$result = $agreement->execute($paymentToken, null, $this->mockPayPalRestCall);
$result = $agreement->execute($paymentToken, $this->apiContext, $this->mockPayPalRestCall);
return $result;
}
@@ -102,7 +98,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
$agreement = new Agreement($request);
// Update the Schema to use a working Plan
$agreement->getPlan()->setId($plan->getId());
$result = $agreement->create(null, $this->mockPayPalRestCall);
$result = $agreement->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}
@@ -114,7 +110,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($agreement)
{
$result = Agreement::get($agreement->getId(), null, $this->mockPayPalRestCall);
$result = Agreement::get($agreement->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($agreement->getId(), $result->getId());
return $result;
@@ -136,7 +132,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
$patches[] = $patch;
$patchRequest = new PatchRequest();
$patchRequest->setPatches($patches);
$result = $agreement->update($patchRequest, null, $this->mockPayPalRestCall);
$result = $agreement->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
}
@@ -149,7 +145,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
{
$this->markTestSkipped('Skipped as the fix is on the way.');
$currency = new Currency($this->operation['request']['body']);
$result = $agreement->setBalance($currency, null, $this->mockPayPalRestCall);
$result = $agreement->setBalance($currency, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
return $agreement;
}
@@ -163,7 +159,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
{
$this->markTestSkipped('Skipped as the fix is on the way.');
$agreementStateDescriptor = new AgreementStateDescriptor($this->operation['request']['body']);
$result = $agreement->billBalance($agreementStateDescriptor, null, $this->mockPayPalRestCall);
$result = $agreement->billBalance($agreementStateDescriptor, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
return $agreement;
}
@@ -176,7 +172,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
public function testGetTransactions($agreement)
{
$params = array('start_date' => date('Y-m-d', strtotime('-15 years')), 'end_date' => date('Y-m-d', strtotime('+5 days')));
$result = Agreement::searchTransactions($agreement->getId(), $params, null, $this->mockPayPalRestCall);
$result = Agreement::searchTransactions($agreement->getId(), $params, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertTrue(is_array($result->getAgreementTransactionList()));
$this->assertTrue(sizeof($result->getAgreementTransactionList()) > 0);
@@ -193,7 +189,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
public function testSuspend($agreement)
{
$agreementStateDescriptor = new AgreementStateDescriptor($this->operation['request']['body']);
$result = $agreement->suspend($agreementStateDescriptor, null, $this->mockPayPalRestCall);
$result = $agreement->suspend($agreementStateDescriptor, $this->apiContext, $this->mockPayPalRestCall);
$this->setupTest($this->getClassName(), 'testGetSuspended');
$get = $this->testGet($agreement);
$this->assertTrue($result);
@@ -209,7 +205,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
public function testReactivate($agreement)
{
$agreementStateDescriptor = new AgreementStateDescriptor($this->operation['request']['body']);
$result = $agreement->reActivate($agreementStateDescriptor, null, $this->mockPayPalRestCall);
$result = $agreement->reActivate($agreementStateDescriptor, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
$this->setupTest($this->getClassName(), 'testGet');
$get = $this->testGet($agreement);
@@ -225,7 +221,7 @@ class BillingAgreementsFunctionalTest extends \PHPUnit_Framework_TestCase
public function testCancel($agreement)
{
$agreementStateDescriptor = new AgreementStateDescriptor($this->operation['request']['body']);
$result = $agreement->cancel($agreementStateDescriptor, null, $this->mockPayPalRestCall);
$result = $agreement->cancel($agreementStateDescriptor, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
$this->setupTest($this->getClassName(), 'testGetCancelled');
$get = $this->testGet($agreement);

View File

@@ -33,7 +33,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
public $mockPayPalRestCall;
public $context;
public $apiContext;
public function setUp()
{
@@ -86,7 +86,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$obj = new Plan($request);
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
self::$obj = $result;
return $result;
@@ -96,7 +96,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$obj = new Plan($request);
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}
@@ -108,7 +108,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($plan)
{
$result = Plan::get($plan->getId(), null, $this->mockPayPalRestCall);
$result = Plan::get($plan->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($plan->getId(), $result->getId());
$this->assertEquals($plan, $result, "", 0, 10, true);
@@ -121,7 +121,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGetList($plan)
{
$result = Plan::all(array('page_size' => '20', 'total_required' => 'yes'), null, $this->mockPayPalRestCall);
$result = Plan::all(array('page_size' => '20', 'total_required' => 'yes'), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$totalPages = $result->getTotalPages();
$found = false;
@@ -135,7 +135,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
}
}
if (!$found) {
$result = Plan::all(array('page' => --$totalPages, 'page_size' => '20', 'total_required' => 'yes'), null, $this->mockPayPalRestCall);
$result = Plan::all(array('page' => --$totalPages, 'page_size' => '20', 'total_required' => 'yes'), $this->apiContext, $this->mockPayPalRestCall);
}
} while ($totalPages > 0 && $found == false);
@@ -160,7 +160,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
$patches[] = $patch;
$patchRequest = new PatchRequest();
$patchRequest->setPatches($patches);
$result = $plan->update($patchRequest, null, $this->mockPayPalRestCall);
$result = $plan->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
}
@@ -181,7 +181,7 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
$patches[] = $patch;
$patchRequest = new PatchRequest();
$patchRequest->setPatches($patches);
$result = $plan->update($patchRequest, null, $this->mockPayPalRestCall);
$result = $plan->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
}
@@ -202,8 +202,8 @@ class BillingPlansFunctionalTest extends \PHPUnit_Framework_TestCase
$patches[] = $patch;
$patchRequest = new PatchRequest();
$patchRequest->setPatches($patches);
$result = $plan->update($patchRequest, null, $this->mockPayPalRestCall);
$result = $plan->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
return Plan::get($plan->getId(), null, $this->mockPayPalRestCall);
return Plan::get($plan->getId(), $this->apiContext, $this->mockPayPalRestCall);
}
}

View File

@@ -25,6 +25,8 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
public $mockPayPalRestCall;
public $apiContext;
public function setUp()
{
$className = $this->getClassName();
@@ -58,7 +60,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$obj = new Invoice($request);
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
self::$obj = $result;
return $result;
@@ -71,7 +73,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($invoice)
{
$result = Invoice::get($invoice->getId(), null, $this->mockPayPalRestCall);
$result = Invoice::get($invoice->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($invoice->getId(), $result->getId());
return $result;
@@ -84,7 +86,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testSend($invoice)
{
$result = $invoice->send(null, $this->mockPayPalRestCall);
$result = $invoice->send($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $invoice;
}
@@ -97,7 +99,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
public function testUpdate($invoice)
{
$this->markTestSkipped('Skipped as the fix is on the way. #PPTIPS-1932');
$result = $invoice->update(null, $this->mockPayPalRestCall);
$result = $invoice->update($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($invoice->getId(), $result->getId());
}
@@ -109,7 +111,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGetAll($invoice)
{
$result = Invoice::getAll(array('page_size' => '20', 'total_count_required' => 'true'), null, $this->mockPayPalRestCall);
$result = Invoice::getAll(array('page_size' => '20', 'total_count_required' => 'true'), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertNotNull($result->getTotalCount());
$totalPages = ceil($result->getTotalCount()/20);
@@ -124,7 +126,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
}
}
if (!$found) {
$result = Invoice::getAll(array('page' => --$totalPages, 'page_size' => '20', 'total_required' => 'yes'), null, $this->mockPayPalRestCall);
$result = Invoice::getAll(array('page' => --$totalPages, 'page_size' => '20', 'total_required' => 'yes'), $this->apiContext, $this->mockPayPalRestCall);
}
} while ($totalPages > 0 && $found == false);
@@ -141,7 +143,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$search = new Search($request);
$result = Invoice::search($search, null, $this->mockPayPalRestCall);
$result = Invoice::search($search, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertNotNull($result->getTotalCount());
}
@@ -155,7 +157,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$notification = new Notification($request);
$result = $invoice->remind($notification, null, $this->mockPayPalRestCall);
$result = $invoice->remind($notification, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
}
@@ -168,7 +170,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$notification = new CancelNotification($request);
$result = $invoice->cancel($notification, null, $this->mockPayPalRestCall);
$result = $invoice->cancel($notification, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
}
@@ -179,7 +181,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testQRCode($invoice)
{
$result = Invoice::qrCode($invoice->getId(), array(), null, $this->mockPayPalRestCall);
$result = Invoice::qrCode($invoice->getId(), array(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertNotNull($result->getImage());
}
@@ -198,7 +200,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
$this->setupTest($this->getClassName(), 'testRecordPayment');
$request = $this->operation['request']['body'];
$paymentDetail = new PaymentDetail($request);
$result = $invoice->recordPayment($paymentDetail, null, $this->mockPayPalRestCall);
$result = $invoice->recordPayment($paymentDetail, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $invoice;
}
@@ -213,7 +215,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$refundDetail = new RefundDetail($request);
$result = $invoice->recordRefund($refundDetail, null, $this->mockPayPalRestCall);
$result = $invoice->recordRefund($refundDetail, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->setupTest($this->getClassName(), 'testDelete');
$invoice = $this->testDelete($invoice);
@@ -230,7 +232,7 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase
$this->setupTest($this->getClassName(), 'testCreate');
$invoice = $this->testCreate($invoice);
$this->setupTest($this->getClassName(), 'testDelete');
$result = $invoice->delete(null, $this->mockPayPalRestCall);
$result = $invoice->delete($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
}

View File

@@ -31,6 +31,8 @@ class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase
public $mockPayPalRestCall;
public $apiContext;
public function setUp()
{
$className = $this->getClassName();
@@ -57,7 +59,7 @@ class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$obj = new Payment($request);
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}
@@ -66,7 +68,7 @@ class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase
{
$request = $this->operation['request']['body'];
$obj = new Payment($request);
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}
@@ -78,7 +80,7 @@ class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($payment)
{
$result = Payment::get($payment->getId(), null, $this->mockPayPalRestCall);
$result = Payment::get($payment->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($payment->getId(), $result->getId());
$this->assertEquals($payment, $result, "", 0, 10, true);
@@ -96,7 +98,7 @@ class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase
$transaction = $transactions[0];
$relatedResources = $transaction->getRelatedResources();
$resource = $relatedResources[0];
$result = Sale::get($resource->getSale()->getId(), null, $this->mockPayPalRestCall);
$result = Sale::get($resource->getSale()->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($resource->getSale()->getId(), $result->getId());
return $result;
@@ -110,7 +112,7 @@ class PaymentsFunctionalTest extends \PHPUnit_Framework_TestCase
public function testRefundSale($sale)
{
$refund = new Refund($this->operation['request']['body']);
$result = $sale->refund($refund, null, $this->mockPayPalRestCall);
$result = $sale->refund($refund, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals('completed', $result->getState());
$this->assertEquals($sale->getId(), $result->getSaleId());

View File

@@ -28,6 +28,8 @@ class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase
public $mockPayPalRestCall;
public $apiContext;
public static $batchId;
public function setUp()
@@ -62,7 +64,7 @@ class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase
}
PayoutsFunctionalTest::$batchId = $obj->getSenderBatchHeader()->getSenderBatchId();
$params = array('sync_mode' => 'true');
$result = $obj->create($params, null, $this->mockPayPalRestCall);
$result = $obj->create($params, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals(PayoutsFunctionalTest::$batchId, $result->getBatchHeader()->getSenderBatchHeader()->getSenderBatchId());
$this->assertEquals('SUCCESS', $result->getBatchHeader()->getBatchStatus());
@@ -80,7 +82,7 @@ class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($payoutBatch)
{
$result = Payout::get($payoutBatch->getBatchHeader()->getPayoutBatchId(), null, $this->mockPayPalRestCall);
$result = Payout::get($payoutBatch->getBatchHeader()->getPayoutBatchId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertNotNull($result->getBatchHeader()->getBatchStatus());
$this->assertEquals(PayoutsFunctionalTest::$batchId, $result->getBatchHeader()->getSenderBatchHeader()->getSenderBatchId());
@@ -96,7 +98,7 @@ class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase
{
$items = $payoutBatch->getItems();
$item = $items[0];
$result = PayoutItem::get($item->getPayoutItemId(), null, $this->mockPayPalRestCall);
$result = PayoutItem::get($item->getPayoutItemId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($item->getPayoutItemId(), $result->getPayoutItemId());
$this->assertEquals($item->getPayoutBatchId(), $result->getPayoutBatchId());
@@ -117,7 +119,7 @@ class PayoutsFunctionalTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Transaction status needs to be Unclaimed for this test ');
return;
}
$result = PayoutItem::cancel($item->getPayoutItemId(), null, $this->mockPayPalRestCall);
$result = PayoutItem::cancel($item->getPayoutItemId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($item->getPayoutItemId(), $result->getPayoutItemId());
$this->assertEquals($item->getPayoutBatchId(), $result->getPayoutBatchId());

View File

@@ -25,6 +25,8 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
public $mockPayPalRestCall;
public $apiContext;
public function setUp()
{
$className = $this->getClassName();
@@ -53,7 +55,7 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
$request = $this->operation['request']['body'];
$obj = new WebProfile($request);
$obj->setName(uniqid());
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}
@@ -65,7 +67,7 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($createProfileResponse)
{
$result = WebProfile::get($createProfileResponse->getId(), null, $this->mockPayPalRestCall);
$result = WebProfile::get($createProfileResponse->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($createProfileResponse->getId(), $result->getId());
$this->assertEquals($this->operation['response']['body']['presentation']['logo_image'], $result->getPresentation()->getLogoImage());
@@ -82,7 +84,7 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGetList($webProfile)
{
$result = WebProfile::get_list(null, $this->mockPayPalRestCall);
$result = WebProfile::get_list($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$found = false;
$foundObject = null;
@@ -110,7 +112,7 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
$boolValue = $webProfile->getInputFields()->getNoShipping();
$newValue = ($boolValue + 1) % 2;
$webProfile->getInputFields()->setNoShipping($newValue);
$result = $webProfile->update(null, $this->mockPayPalRestCall);
$result = $webProfile->update($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($webProfile->getInputFields()->getNoShipping(), $newValue);
}
@@ -132,7 +134,7 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
"path": "/flow_config/landing_page_type"
}');
$result = $webProfile->partial_update($patches, null, $this->mockPayPalRestCall);
$result = $webProfile->partial_update($patches, $this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
}
@@ -144,7 +146,7 @@ class WebProfileFunctionalTest extends \PHPUnit_Framework_TestCase
{
$webProfile = new WebProfile();
$webProfile->setId($createProfileResponse->getId());
$result = $webProfile->delete(null, $this->mockPayPalRestCall);
$result = $webProfile->delete($this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
}

View File

@@ -38,6 +38,8 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
public $mockPayPalRestCall;
public $apiContext;
public function setUp()
{
$className = $this->getClassName();
@@ -68,12 +70,12 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
$obj->setUrl($obj->getUrl() . '?rand=' . uniqid());
$result = null;
try {
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
} catch (PayPalConnectionException $ex) {
$data = $ex->getData();
if (strpos($data,'WEBHOOK_NUMBER_LIMIT_EXCEEDED') !== false) {
$this->deleteAll();
$result = $obj->create(null, $this->mockPayPalRestCall);
$result = $obj->create($this->apiContext, $this->mockPayPalRestCall);
} else {
$this->fail($ex->getMessage());
}
@@ -84,9 +86,9 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
public function deleteAll()
{
$result = Webhook::getAll(null, $this->mockPayPalRestCall);
$result = Webhook::getAll($this->apiContext, $this->mockPayPalRestCall);
foreach ($result->getWebhooks() as $webhookObject) {
$webhookObject->delete(null, $this->mockPayPalRestCall);
$webhookObject->delete($this->apiContext, $this->mockPayPalRestCall);
}
}
@@ -97,7 +99,7 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGet($webhook)
{
$result = Webhook::get($webhook->getId(), null, $this->mockPayPalRestCall);
$result = Webhook::get($webhook->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals($webhook->getId(), $result->getId());
$this->assertEquals($webhook, $result, "", 0, 10, true);
@@ -111,7 +113,7 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGetSubscribedEventTypes($webhook)
{
$result = WebhookEventType::subscribedEventTypes($webhook->getId(), null, $this->mockPayPalRestCall);
$result = WebhookEventType::subscribedEventTypes($webhook->getId(), $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$this->assertEquals(2, sizeof($result->getEventTypes()));
return $result;
@@ -124,7 +126,7 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testGetAll($webhook)
{
$result = Webhook::getAll(null, $this->mockPayPalRestCall);
$result = Webhook::getAll($this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$found = false;
$foundObject = null;
@@ -162,7 +164,7 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
$patchRequest = new PatchRequest();
$patchRequest->setPatches($patches);
$result = $webhook->update($patchRequest, null, $this->mockPayPalRestCall);
$result = $webhook->update($patchRequest, $this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
$found = false;
$foundObject = null;
@@ -181,13 +183,13 @@ class WebhookFunctionalTest extends \PHPUnit_Framework_TestCase
*/
public function testDelete($webhook)
{
$result = $webhook->delete(null, $this->mockPayPalRestCall);
$result = $webhook->delete($this->apiContext, $this->mockPayPalRestCall);
$this->assertTrue($result);
}
public function testEventSearch()
{
$result = WebhookEvent::all(array(),null, $this->mockPayPalRestCall);
$result = WebhookEvent::all(array(),$this->apiContext, $this->mockPayPalRestCall);
$this->assertNotNull($result);
return $result;
}

View File

@@ -14,16 +14,21 @@ class Setup
public static function SetUpForFunctionalTests(\PHPUnit_Framework_TestCase &$test)
{
$context = new ApiContext();
$context->setConfig(array(
$configs = array(
'mode' => 'sandbox',
'http.ConnectionTimeOut' => 30,
'log.LogEnabled' => true,
'log.FileName' => '../PayPal.log',
'log.LogLevel' => 'FINE',
'validation.level' => 'warning'
));
'validation.level' => 'log'
);
$test->apiContext = new ApiContext(
new OAuthTokenCredential('AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS', 'EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL')
);
$test->apiContext->setConfig($configs);
//PayPalConfigManager::getInstance()->addConfigFromIni(__DIR__. '/../../../sdk_config.ini');
//PayPalConfigManager::getInstance()->addConfigs($configs);
PayPalCredentialManager::getInstance()->setCredentialObject(PayPalCredentialManager::getInstance()->getCredentialObject('acct1'));
self::$mode = getenv('REST_MODE') ? getenv('REST_MODE') : 'mock';