forked from LiveCarta/PayPal-PHP-SDK
Updated Payment APIs
- Updated SDK Models to latest Payment APIs - Updated Unit Tests
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user