From 243cfa680b9d70e4e86911a0ca1f773bce6ce2fc Mon Sep 17 00:00:00 2001 From: brunoric Date: Fri, 22 Aug 2014 16:58:54 -0300 Subject: [PATCH 1/3] Adding .idea project folder to gitignore file. This will be usefull for PhpStorm users. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e9c37ab..437354b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ build *.log # IDE +.idea .project .settings .buildpath From cc67faf8224f0c6b71a54afcb294ee1375a2571a Mon Sep 17 00:00:00 2001 From: brunoric Date: Fri, 22 Aug 2014 16:59:42 -0300 Subject: [PATCH 2/3] Adding the missing get and setter tests. --- tests/PayPal/Test/Api/AuthorizationTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/PayPal/Test/Api/AuthorizationTest.php b/tests/PayPal/Test/Api/AuthorizationTest.php index 73b2f25..287abc8 100644 --- a/tests/PayPal/Test/Api/AuthorizationTest.php +++ b/tests/PayPal/Test/Api/AuthorizationTest.php @@ -19,9 +19,11 @@ use PayPal\Exception\PPConnectionException; 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 $currency = "USD"; public static $total = "1.12"; public static $href = "USD"; @@ -90,20 +92,24 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase { 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); $this->authorizations['partial'] = $authorization; $this->authorizations['full'] = self::createAuthorization(); } - public function testGetterSetter() { + public function testGetterSetter() { $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()); $authorization = $this->authorizations['full']; $this->assertEquals(AmountTest::$currency, $authorization->getAmount()->getCurrency()); From bcd0b80e8568bab7a039a0e6365dfd26b6e9e169 Mon Sep 17 00:00:00 2001 From: brunoric Date: Fri, 22 Aug 2014 17:49:30 -0300 Subject: [PATCH 3/3] Adding \InvalidArgumentException tests to void() and reauthorize(). --- tests/PayPal/Test/Api/AuthorizationTest.php | 22 +++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/PayPal/Test/Api/AuthorizationTest.php b/tests/PayPal/Test/Api/AuthorizationTest.php index 287abc8..64d45a1 100644 --- a/tests/PayPal/Test/Api/AuthorizationTest.php +++ b/tests/PayPal/Test/Api/AuthorizationTest.php @@ -143,9 +143,15 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase { $void = $auth->void(); $this->assertNotNull($void->getId()); + $auth->setId(null); + try { + $auth->void(); + } catch (\InvalidArgumentException $ex) { + $this->assertEquals($ex->getMessage(), "Id cannot be null"); + } } - public function testReauthorize(){ + public function testReauthorize() { $authorization = Authorization::get('7GH53639GA425732B'); $amount = new Amount(); @@ -153,10 +159,18 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase { $amount->setTotal("1.00"); $authorization->setAmount($amount); - try{ - $reauthorization = $authorization->reauthorize(); - }catch (PPConnectionException $ex){ + try { + $authorization->reauthorize(); + } catch (PPConnectionException $ex){ + var_dump($ex->getMessage()); $this->assertEquals(strpos($ex->getMessage(),"500"), false); } + + $authorization->setId(null); + try { + $authorization->reauthorize(); + } catch (\InvalidArgumentException $ex) { + $this->assertEquals($ex->getMessage(), "Id cannot be null"); + } } }