From 6e14f51aa5fc25b7e07dcf7b9b8a21d6339f451d Mon Sep 17 00:00:00 2001 From: Jay Patel Date: Sun, 21 Sep 2014 20:37:34 -0500 Subject: [PATCH] Updated Testing Framework fixing Travis Builds - Added Group and Catching errors --- phpunit.xml | 8 +++ tests/PayPal/Test/Api/AddressTest.php | 2 +- tests/PayPal/Test/Api/AuthorizationTest.php | 11 +++- tests/PayPal/Test/Api/CaptureTest.php | 59 ++++++++++++--------- tests/PayPal/Test/Api/CreditCardTest.php | 3 ++ tests/PayPal/Test/Api/PaymentTest.php | 3 ++ tests/PayPal/Test/Api/SaleTest.php | 44 +++++++++------ 7 files changed, 85 insertions(+), 45 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 3738b96..8aec30d 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -15,6 +15,14 @@ + + + + integration + + + + assertEquals(self::$countryCode, $this->address->getCountryCode()); $this->assertEquals(self::$phone, $this->address->getPhone()); } - + public function testSerializeDeserialize() { $a1 = $this->address; diff --git a/tests/PayPal/Test/Api/AuthorizationTest.php b/tests/PayPal/Test/Api/AuthorizationTest.php index 3f3ea9b..a575044 100644 --- a/tests/PayPal/Test/Api/AuthorizationTest.php +++ b/tests/PayPal/Test/Api/AuthorizationTest.php @@ -122,6 +122,10 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase { $a2->fromJson($a1->toJson()); $this->assertEquals($a1, $a2); } + + /** + * @group integration + */ public function testOperations() { try { $authId = self::authorize(); @@ -150,13 +154,16 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase { } catch (\InvalidArgumentException $ex) { $this->assertEquals($ex->getMessage(), "Id cannot be null"); } - } catch (\PayPal\Exception\PPConnectionException $ex) { + } catch (PPConnectionException $ex) { $this->markTestSkipped( 'Tests failing because of intermittent failures in Paypal Sandbox environment.' . $ex->getMessage() ); } } - + + /** + * @group integration + */ public function testReauthorize() { $authorization = Authorization::get('7GH53639GA425732B'); diff --git a/tests/PayPal/Test/Api/CaptureTest.php b/tests/PayPal/Test/Api/CaptureTest.php index a1162fd..7991e44 100644 --- a/tests/PayPal/Test/Api/CaptureTest.php +++ b/tests/PayPal/Test/Api/CaptureTest.php @@ -55,33 +55,42 @@ class CaptureTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($c1, $c2); } - + + /** + * @group integration + */ public function testOperations() { - $authId = AuthorizationTest::authorize(); - $auth = Authorization::get($authId); - - $amount = new Amount(); - $amount->setCurrency("USD"); - $amount->setTotal("1.00"); - - $captr = new Capture(); - $captr->setId($authId); - $captr->setAmount($amount); - - $capt = $auth->capture($captr); - $captureId = $capt->getId(); - $this->assertNotNull($captureId); - - $refund = new Refund(); - $refund->setId($captureId); - $refund->setAmount($amount); - - $capture = Capture::get($captureId); - $this->assertNotNull($capture->getId()); - - $retund = $capture->refund($refund); - $this->assertNotNull($retund->getId()); + try { + $authId = AuthorizationTest::authorize(); + $auth = Authorization::get($authId); + + $amount = new Amount(); + $amount->setCurrency("USD"); + $amount->setTotal("1.00"); + + $captr = new Capture(); + $captr->setId($authId); + $captr->setAmount($amount); + + $capt = $auth->capture($captr); + $captureId = $capt->getId(); + $this->assertNotNull($captureId); + + $refund = new Refund(); + $refund->setId($captureId); + $refund->setAmount($amount); + + $capture = Capture::get($captureId); + $this->assertNotNull($capture->getId()); + + $retund = $capture->refund($refund); + $this->assertNotNull($retund->getId()); + } catch (PPConnectionException $ex) { + $this->markTestSkipped( + 'Tests failing because of intermittent failures in Paypal Sandbox environment.' . $ex->getMessage() + ); + } } } \ No newline at end of file diff --git a/tests/PayPal/Test/Api/CreditCardTest.php b/tests/PayPal/Test/Api/CreditCardTest.php index 84cb96b..fd0bb03 100644 --- a/tests/PayPal/Test/Api/CreditCardTest.php +++ b/tests/PayPal/Test/Api/CreditCardTest.php @@ -71,6 +71,9 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($c1, $c2); } + /** + * @group integration + */ public function testOperations() { $c1 = $this->cards['full']; diff --git a/tests/PayPal/Test/Api/PaymentTest.php b/tests/PayPal/Test/Api/PaymentTest.php index 6e92d23..fd0ce9d 100644 --- a/tests/PayPal/Test/Api/PaymentTest.php +++ b/tests/PayPal/Test/Api/PaymentTest.php @@ -66,6 +66,9 @@ class PaymentTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($p2, $this->payments['full']); } + /** + * @group integration + */ public function testOperations() { $p1 = $this->payments['new']; diff --git a/tests/PayPal/Test/Api/SaleTest.php b/tests/PayPal/Test/Api/SaleTest.php index b4c6972..1794725 100644 --- a/tests/PayPal/Test/Api/SaleTest.php +++ b/tests/PayPal/Test/Api/SaleTest.php @@ -7,6 +7,7 @@ use PayPal\Test\Constants; use PayPal\Test\Api\AmountTest; use PayPal\Test\Api\PaymentTest; use PayPal\Test\Api\LinksTest; +use PayPal\Exception\PPConnectionException; class SaleTest extends \PHPUnit_Framework_TestCase { @@ -51,23 +52,32 @@ class SaleTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($s1, $s2); } - + + /** + * @group integration + */ public function testOperations() { - $payment = PaymentTest::createNewPayment(); - $payment->create(); - - $transactions = $payment->getTransactions(); - $resources = $transactions[0]->getRelatedResources(); - $saleId = $resources[0]->getSale()->getId(); - - $sale = Sale::get($saleId); - $this->assertNotNull($sale); - - $refund = new Refund(); - $refund->setAmount(AmountTest::createAmount()); - $sale->refund($refund); - - $this->setExpectedException('\InvalidArgumentException'); - $sale->refund(NULL); + try { + $payment = PaymentTest::createNewPayment(); + $payment->create(); + + $transactions = $payment->getTransactions(); + $resources = $transactions[0]->getRelatedResources(); + $saleId = $resources[0]->getSale()->getId(); + + $sale = Sale::get($saleId); + $this->assertNotNull($sale); + + $refund = new Refund(); + $refund->setAmount(AmountTest::createAmount()); + $sale->refund($refund); + + $this->setExpectedException('\InvalidArgumentException'); + $sale->refund(NULL); + } catch (PPConnectionException $ex) { + $this->markTestSkipped( + 'Tests failing because of intermittent failures in Paypal Sandbox environment.' . $ex->getMessage() + ); + } } } \ No newline at end of file