From 50b09bdbdeb9881a50739656beb367f54a57e4cb Mon Sep 17 00:00:00 2001 From: Ganesh Hegde <1ganesh1@facebook.com> Date: Tue, 28 May 2013 10:08:34 +0530 Subject: [PATCH] testcases updated updated testcases to match new json schema and updates with camel case function names --- tests/PayPal/Test/Api/AddressTest.php | 10 ++--- tests/PayPal/Test/Api/AmountTest.php | 4 +- tests/PayPal/Test/Api/AuthorizationTest.php | 14 +++---- tests/PayPal/Test/Api/CaptureTest.php | 17 +++----- tests/PayPal/Test/Api/CreditCardTest.php | 34 ++++++++-------- tests/PayPal/Test/Api/CreditCardTokenTest.php | 8 ++-- ...{AmountDetailsTest.php => DetailsTest.php} | 8 ++-- .../PayPal/Test/Api/FundingInstrumentTest.php | 8 ++-- tests/PayPal/Test/Api/ItemListTest.php | 4 +- tests/PayPal/Test/Api/LinkTest.php | 40 ------------------- tests/PayPal/Test/Api/LinksTest.php | 40 +++++++++++++++++++ tests/PayPal/Test/Api/PayeeTest.php | 4 +- tests/PayPal/Test/Api/PayerInfoTest.php | 16 ++++---- tests/PayPal/Test/Api/PayerTest.php | 14 +++---- tests/PayPal/Test/Api/PaymentHistoryTest.php | 4 +- tests/PayPal/Test/Api/PaymentTest.php | 20 ++++------ tests/PayPal/Test/Api/RefundTest.php | 19 ++++----- .../PayPal/Test/Api/RelatedResourcesTest.php | 35 ++++++++++++++++ tests/PayPal/Test/Api/SaleTest.php | 17 ++++---- tests/PayPal/Test/Api/ShippingAddressTest.php | 15 +++---- tests/PayPal/Test/Api/SubTransactionTest.php | 35 ---------------- tests/PayPal/Test/Api/TransactionTest.php | 10 ++--- 22 files changed, 179 insertions(+), 197 deletions(-) rename tests/PayPal/Test/Api/{AmountDetailsTest.php => DetailsTest.php} (86%) delete mode 100644 tests/PayPal/Test/Api/LinkTest.php create mode 100644 tests/PayPal/Test/Api/LinksTest.php create mode 100644 tests/PayPal/Test/Api/RelatedResourcesTest.php delete mode 100644 tests/PayPal/Test/Api/SubTransactionTest.php diff --git a/tests/PayPal/Test/Api/AddressTest.php b/tests/PayPal/Test/Api/AddressTest.php index 3909d09..ec271c9 100644 --- a/tests/PayPal/Test/Api/AddressTest.php +++ b/tests/PayPal/Test/Api/AddressTest.php @@ -23,10 +23,9 @@ class AddressTest extends \PHPUnit_Framework_TestCase { $addr->setLine2(self::$line2); $addr->setCity(self::$city); $addr->setState(self::$state); - $addr->setPostal_code(self::$postalCode); - $addr->setCountry_code(self::$countryCode); + $addr->setPostalCode(self::$postalCode); + $addr->setCountryCode(self::$countryCode); $addr->setPhone(self::$phone); - $addr->setType(self::$type); return $addr; } @@ -39,10 +38,9 @@ class AddressTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(self::$line2, $this->address->getLine2()); $this->assertEquals(self::$city, $this->address->getCity()); $this->assertEquals(self::$state, $this->address->getState()); - $this->assertEquals(self::$postalCode, $this->address->getPostal_code()); - $this->assertEquals(self::$countryCode, $this->address->getCountry_code()); + $this->assertEquals(self::$postalCode, $this->address->getPostalCode()); + $this->assertEquals(self::$countryCode, $this->address->getCountryCode()); $this->assertEquals(self::$phone, $this->address->getPhone()); - $this->assertEquals(self::$type, $this->address->getType()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/AmountTest.php b/tests/PayPal/Test/Api/AmountTest.php index c1028c8..7f24e7b 100644 --- a/tests/PayPal/Test/Api/AmountTest.php +++ b/tests/PayPal/Test/Api/AmountTest.php @@ -24,14 +24,14 @@ class AmountTest extends \PHPUnit_Framework_TestCase { $this->amounts['partial'] = self::createAmount(); $amount = self::createAmount(); - $amount->setDetails(AmountDetailsTest::createAmountDetails()); + $amount->setDetails(DetailsTest::createAmountDetails()); $this->amounts['full'] = $amount; } public function testGetterSetter() { $this->assertEquals(self::$currency, $this->amounts['partial']->getCurrency()); $this->assertEquals(self::$total, $this->amounts['partial']->getTotal()); - $this->assertEquals(AmountDetailsTest::$fee, $this->amounts['full']->getDetails()->getFee()); + $this->assertEquals(DetailsTest::$fee, $this->amounts['full']->getDetails()->getFee()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/AuthorizationTest.php b/tests/PayPal/Test/Api/AuthorizationTest.php index baec44f..ba104f9 100644 --- a/tests/PayPal/Test/Api/AuthorizationTest.php +++ b/tests/PayPal/Test/Api/AuthorizationTest.php @@ -3,7 +3,7 @@ namespace PayPal\Test\Api; use PayPal\Api\Amount; use PayPal\Api\Authorization; -use PayPal\Api\Link; +use PayPal\Api\Links; use PayPal\Test\Constants; class AuthorizationTest extends \PHPUnit_Framework_TestCase { @@ -24,22 +24,22 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase { public static function createAuthorization() { $authorization = new Authorization(); - $authorization->setCreate_time(self::$create_time); + $authorization->setCreateTime(self::$create_time); $authorization->setId(self::$id); $authorization->setState(self::$state); $authorization->setAmount(AmountTest::createAmount()); - $authorization->setLinks(array(LinkTest::createLink())); + $authorization->setLinks(array(LinksTest::createLinks())); return $authorization; } public function setup() { $authorization = new Authorization(); - $authorization->setCreate_time(self::$create_time); + $authorization->setCreateTime(self::$create_time); $authorization->setId(self::$id); $authorization->setState(self::$state); - $authorization->setParent_payment(self::$parent_payment); + $authorization->setParentPayment(self::$parent_payment); $this->authorizations['partial'] = $authorization; @@ -48,10 +48,10 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase { public function testGetterSetter() { $authorization = $this->authorizations['partial']; - $this->assertEquals(self::$create_time, $authorization->getCreate_time()); + $this->assertEquals(self::$create_time, $authorization->getCreateTime()); $this->assertEquals(self::$id, $authorization->getId()); $this->assertEquals(self::$state, $authorization->getState()); - $this->assertEquals(self::$parent_payment, $authorization->getParent_payment()); + $this->assertEquals(self::$parent_payment, $authorization->getParentPayment()); $authorization = $this->authorizations['full']; $this->assertEquals(AmountTest::$currency, $authorization->getAmount()->getCurrency()); diff --git a/tests/PayPal/Test/Api/CaptureTest.php b/tests/PayPal/Test/Api/CaptureTest.php index 45a0a88..56000dc 100644 --- a/tests/PayPal/Test/Api/CaptureTest.php +++ b/tests/PayPal/Test/Api/CaptureTest.php @@ -10,18 +10,15 @@ class CaptureTest extends \PHPUnit_Framework_TestCase { public static $authorization_id = "AUTH-123"; public static $create_time = "2013-02-28T00:00:00Z"; - public static $description = "Test capture"; public static $id = "C-5678"; public static $parent_payment = "PAY-123"; public static $state = "Created"; public static function createCapture() { $capture = new Capture(); - $capture->setAuthorization_id(self::$authorization_id); - $capture->setCreate_time(self::$create_time); - $capture->setDescription(self::$description); + $capture->setCreateTime(self::$create_time); $capture->setId(self::$id); - $capture->setParent_payment(self::$parent_payment); + $capture->setParentPayment(self::$parent_payment); $capture->setState(self::$state); return $capture; @@ -32,21 +29,19 @@ class CaptureTest extends \PHPUnit_Framework_TestCase { $capture = self::createCapture(); $capture->setAmount(AmountTest::createAmount()); - $capture->setLinks(array(LinkTest::createLink())); + $capture->setLinks(array(LinksTest::createLinks())); $this->captures['full'] = $capture; } public function testGetterSetter() { - $this->assertEquals(self::$authorization_id, $this->captures['partial']->getAuthorization_id()); - $this->assertEquals(self::$create_time, $this->captures['partial']->getCreate_time()); - $this->assertEquals(self::$description, $this->captures['partial']->getDescription()); + $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']->getParent_payment()); + $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(); - $this->assertEquals(LinkTest::$href, $links[0]->getHref()); + $this->assertEquals(LinksTest::$href, $links[0]->getHref()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/CreditCardTest.php b/tests/PayPal/Test/Api/CreditCardTest.php index e442e70..c4ae466 100644 --- a/tests/PayPal/Test/Api/CreditCardTest.php +++ b/tests/PayPal/Test/Api/CreditCardTest.php @@ -26,23 +26,23 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase { $card = new CreditCard(); $card->setType(self::$cardType); $card->setNumber(self::$cardNumber); - $card->setExpire_month(self::$expireMonth); - $card->setExpire_year(self::$expireYear); + $card->setExpireMonth(self::$expireMonth); + $card->setExpireYear(self::$expireYear); $card->setCvv2(self::$cvv); - $card->setFirst_name(self::$firstName); - $card->setLast_name(self::$lastName); + $card->setFirstName(self::$firstName); + $card->setLastName(self::$lastName); $card->setId(self::$id); - $card->setValid_until(self::$validUntil); + $card->setValidUntil(self::$validUntil); $card->setState(self::$state); - $card->setPayer_id(self::$payerId); + $card->setPayerId(self::$payerId); return $card; } public function setup() { $card = self::createCreditCard(); - $card->setBilling_address(AddressTest::createAddress()); - $card->setLinks(array(LinkTest::createLink())); + $card->setBillingAddress(AddressTest::createAddress()); + $card->setLinks(array(LinksTest::createLinks())); $this->cards['full'] = $card; $card = self::createCreditCard(); @@ -53,20 +53,20 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase { $c = $this->cards['partial']; $this->assertEquals(self::$cardType, $c->getType()); $this->assertEquals(self::$cardNumber, $c->getNumber()); - $this->assertEquals(self::$expireMonth, $c->getExpire_month()); - $this->assertEquals(self::$expireYear, $c->getExpire_year()); + $this->assertEquals(self::$expireMonth, $c->getExpireMonth()); + $this->assertEquals(self::$expireYear, $c->getExpireYear()); $this->assertEquals(self::$cvv, $c->getCvv2()); - $this->assertEquals(self::$firstName, $c->getFirst_name()); - $this->assertEquals(self::$lastName, $c->getLast_name()); + $this->assertEquals(self::$firstName, $c->getFirstName()); + $this->assertEquals(self::$lastName, $c->getLastName()); $this->assertEquals(self::$id, $c->getId()); - $this->assertEquals(self::$validUntil, $c->getValid_until()); + $this->assertEquals(self::$validUntil, $c->getValidUntil()); $this->assertEquals(self::$state, $c->getState()); - $this->assertEquals(self::$payerId, $c->getPayer_id()); + $this->assertEquals(self::$payerId, $c->getPayerId()); $c = $this->cards['full']; - $this->assertEquals(AddressTest::$line1, $c->getBilling_address()->getLine1()); + $this->assertEquals(AddressTest::$line1, $c->getBillingAddress()->getLine1()); $link = $c->getLinks(); - $this->assertEquals(LinkTest::$href, $link[0]->getHref()); + $this->assertEquals(LinksTest::$href, $link[0]->getHref()); } public function testSerializeDeserialize() { @@ -87,7 +87,7 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase { $this->assertNotNull($c1->getId()); $c2 = CreditCard::get($c1->getId()); - $this->assertEquals($c1->getBilling_address(), $c2->getBilling_address()); + $this->assertEquals($c1->getBillingAddress(), $c2->getBillingAddress()); $this->assertGreaterThan(0, count($c2->getLinks())); $this->assertEquals(self::$cardType, $c2->getType()); $this->assertNotNull($c2->getState()); diff --git a/tests/PayPal/Test/Api/CreditCardTokenTest.php b/tests/PayPal/Test/Api/CreditCardTokenTest.php index 75de222..d1f8db9 100644 --- a/tests/PayPal/Test/Api/CreditCardTokenTest.php +++ b/tests/PayPal/Test/Api/CreditCardTokenTest.php @@ -13,8 +13,8 @@ class CreditCardTokenTest extends \PHPUnit_Framework_TestCase { public static function createCreditCardToken() { $ccToken = new CreditCardToken(); - $ccToken->setPayer_id(self::$payerId); - $ccToken->setCredit_card_id(self::$creditCardId); + $ccToken->setPayerId(self::$payerId); + $ccToken->setCreditCardId(self::$creditCardId); return $ccToken; } @@ -23,8 +23,8 @@ class CreditCardTokenTest extends \PHPUnit_Framework_TestCase { } public function testGetterSetter() { - $this->assertEquals(self::$payerId, $this->ccToken->getPayer_id()); - $this->assertEquals(self::$creditCardId, $this->ccToken->getCredit_card_id()); + $this->assertEquals(self::$payerId, $this->ccToken->getPayerId()); + $this->assertEquals(self::$creditCardId, $this->ccToken->getCreditCardId()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/AmountDetailsTest.php b/tests/PayPal/Test/Api/DetailsTest.php similarity index 86% rename from tests/PayPal/Test/Api/AmountDetailsTest.php rename to tests/PayPal/Test/Api/DetailsTest.php index 1456433..ae1cba9 100644 --- a/tests/PayPal/Test/Api/AmountDetailsTest.php +++ b/tests/PayPal/Test/Api/DetailsTest.php @@ -1,10 +1,10 @@ setSubtotal(self::$subtotal); $amountDetails->setTax(self::$tax); $amountDetails->setShipping(self::$shipping); @@ -37,7 +37,7 @@ class AmountDetailsTest extends \PHPUnit_Framework_TestCase { public function testSerializeDeserialize() { $a1 = $this->amountDetails; - $a2 = new AmountDetails(); + $a2 = new Details(); $a2->fromJson($a1->toJson()); $this->assertEquals($a1, $a2); diff --git a/tests/PayPal/Test/Api/FundingInstrumentTest.php b/tests/PayPal/Test/Api/FundingInstrumentTest.php index 5a93c36..cb420d6 100644 --- a/tests/PayPal/Test/Api/FundingInstrumentTest.php +++ b/tests/PayPal/Test/Api/FundingInstrumentTest.php @@ -11,8 +11,8 @@ class FundingInstrumentTest extends \PHPUnit_Framework_TestCase { public static function createFundingInstrument() { $fi = new FundingInstrument(); - $fi->setCredit_card(CreditCardTest::createCreditCard()); - $fi->setCredit_card_token(CreditCardTokenTest::createCreditCardToken()); + $fi->setCreditCard(CreditCardTest::createCreditCard()); + $fi->setCreditCardToken(CreditCardTokenTest::createCreditCardToken()); return $fi; } @@ -21,9 +21,9 @@ class FundingInstrumentTest extends \PHPUnit_Framework_TestCase { } public function testGetterSetter() { - $this->assertEquals(CreditCardTest::$cardNumber, $this->fi->getCredit_card()->getNumber()); + $this->assertEquals(CreditCardTest::$cardNumber, $this->fi->getCreditCard()->getNumber()); $this->assertEquals(CreditCardTokenTest::$creditCardId, - $this->fi->getCredit_card_token()->getCredit_card_id()); + $this->fi->getCreditCardToken()->getCreditCardId()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/ItemListTest.php b/tests/PayPal/Test/Api/ItemListTest.php index 96a6d2a..fe5f870 100644 --- a/tests/PayPal/Test/Api/ItemListTest.php +++ b/tests/PayPal/Test/Api/ItemListTest.php @@ -21,7 +21,7 @@ class ItemListTest extends \PHPUnit_Framework_TestCase { $itemList = new ItemList(); $itemList->setItems(array($item)); - $itemList->setShipping_address(ShippingAddressTest::createAddress()); + $itemList->setShippingAddress(ShippingAddressTest::createAddress()); return $itemList; } @@ -33,7 +33,7 @@ class ItemListTest extends \PHPUnit_Framework_TestCase { public function testGetterSetters() { $items = $this->items->getItems(); $this->assertEquals(ItemTest::createItem(), $items[0]); - $this->assertEquals(ShippingAddressTest::createAddress(), $this->items->getShipping_address()); + $this->assertEquals(ShippingAddressTest::createAddress(), $this->items->getShippingAddress()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/LinkTest.php b/tests/PayPal/Test/Api/LinkTest.php deleted file mode 100644 index 8deec92..0000000 --- a/tests/PayPal/Test/Api/LinkTest.php +++ /dev/null @@ -1,40 +0,0 @@ -setHref(self::$href); - $link->setRel(self::$rel); - $link->setMethod(self::$method); - - return $link; - } - - public function setup() { - $this->link = self::createLink(); - } - - public function testGetterSetters() { - $this->assertEquals(self::$href, $this->link->getHref()); - $this->assertEquals(self::$rel, $this->link->getRel()); - $this->assertEquals(self::$method, $this->link->getMethod()); - } - - public function testSerializeDeserialize() { - $link2 = new Link(); - $link2->fromJson($this->link->toJSON()); - $this->assertEquals($this->link, $link2); - } -} \ No newline at end of file diff --git a/tests/PayPal/Test/Api/LinksTest.php b/tests/PayPal/Test/Api/LinksTest.php new file mode 100644 index 0000000..68da69a --- /dev/null +++ b/tests/PayPal/Test/Api/LinksTest.php @@ -0,0 +1,40 @@ +setHref(self::$href); + $links->setRel(self::$rel); + $links->setMethod(self::$method); + + return $links; + } + + public function setup() { + $this->links = self::createLinks(); + } + + public function testGetterSetters() { + $this->assertEquals(self::$href, $this->links->getHref()); + $this->assertEquals(self::$rel, $this->links->getRel()); + $this->assertEquals(self::$method, $this->links->getMethod()); + } + + public function testSerializeDeserialize() { + $link2 = new Links(); + $link2->fromJson($this->links->toJSON()); + $this->assertEquals($this->links, $link2); + } +} \ No newline at end of file diff --git a/tests/PayPal/Test/Api/PayeeTest.php b/tests/PayPal/Test/Api/PayeeTest.php index 95687c9..ea9469f 100644 --- a/tests/PayPal/Test/Api/PayeeTest.php +++ b/tests/PayPal/Test/Api/PayeeTest.php @@ -17,7 +17,7 @@ class PayeeTest extends \PHPUnit_Framework_TestCase { public static function createPayee() { $payee = new Payee(); $payee->setEmail(self::$email); - $payee->setMerchant_id(self::$merchant_id); + $payee->setMerchantId(self::$merchant_id); $payee->setPhone(self::$phone); return $payee; @@ -29,7 +29,7 @@ class PayeeTest extends \PHPUnit_Framework_TestCase { public function testGetterSetter() { $this->assertEquals(self::$email, $this->payee->getEmail()); - $this->assertEquals(self::$merchant_id, $this->payee->getMerchant_id()); + $this->assertEquals(self::$merchant_id, $this->payee->getMerchantId()); $this->assertEquals(self::$phone, $this->payee->getPhone()); } diff --git a/tests/PayPal/Test/Api/PayerInfoTest.php b/tests/PayPal/Test/Api/PayerInfoTest.php index ddf584d..b1f5858 100644 --- a/tests/PayPal/Test/Api/PayerInfoTest.php +++ b/tests/PayPal/Test/Api/PayerInfoTest.php @@ -17,11 +17,11 @@ class PayerInfoTest extends \PHPUnit_Framework_TestCase { public static function createPayerInfo() { $payerInfo = new PayerInfo(); $payerInfo->setEmail(self::$email); - $payerInfo->setFirst_name(self::$firstName); - $payerInfo->setLast_name(self::$lastName); + $payerInfo->setFirstName(self::$firstName); + $payerInfo->setLastName(self::$lastName); $payerInfo->setPhone(self::$phone); - $payerInfo->setPayer_id(self::$payerId); - $payerInfo->setShipping_address(AddressTest::createAddress()); + $payerInfo->setPayerId(self::$payerId); + $payerInfo->setShippingAddress(AddressTest::createAddress()); return $payerInfo; } @@ -32,11 +32,11 @@ class PayerInfoTest extends \PHPUnit_Framework_TestCase { public function testGetterSetter() { $this->assertEquals(self::$email, $this->payerInfo->getEmail()); - $this->assertEquals(self::$firstName, $this->payerInfo->getFirst_name()); - $this->assertEquals(self::$lastName, $this->payerInfo->getLast_name()); + $this->assertEquals(self::$firstName, $this->payerInfo->getFirstName()); + $this->assertEquals(self::$lastName, $this->payerInfo->getLastName()); $this->assertEquals(self::$phone, $this->payerInfo->getPhone()); - $this->assertEquals(self::$payerId, $this->payerInfo->getPayer_id()); - $this->assertEquals(AddressTest::$line1, $this->payerInfo->getShipping_address()->getLine1()); + $this->assertEquals(self::$payerId, $this->payerInfo->getPayerId()); + $this->assertEquals(AddressTest::$line1, $this->payerInfo->getShippingAddress()->getLine1()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/PayerTest.php b/tests/PayPal/Test/Api/PayerTest.php index f956a15..7568a3c 100644 --- a/tests/PayPal/Test/Api/PayerTest.php +++ b/tests/PayPal/Test/Api/PayerTest.php @@ -15,9 +15,9 @@ class PayerTest extends \PHPUnit_Framework_TestCase { public static function createPayer() { $payer = new Payer(); - $payer->setPayment_method(self::$paymentMethod); - $payer->setPayer_info(PayerInfoTest::createPayerInfo()); - $payer->setFunding_instruments(array(FundingInstrumentTest::createFundingInstrument())); + $payer->setPaymentMethod(self::$paymentMethod); + $payer->setPayerInfo(PayerInfoTest::createPayerInfo()); + $payer->setFundingInstruments(array(FundingInstrumentTest::createFundingInstrument())); return $payer; } @@ -27,11 +27,11 @@ class PayerTest extends \PHPUnit_Framework_TestCase { } public function testGetterSetter() { - $this->assertEquals(self::$paymentMethod, $this->payer->getPayment_method()); - $this->assertEquals(PayerInfoTest::$email, $this->payer->getPayer_info()->getEmail()); + $this->assertEquals(self::$paymentMethod, $this->payer->getPaymentMethod()); + $this->assertEquals(PayerInfoTest::$email, $this->payer->getPayerInfo()->getEmail()); - $fi = $this->payer->getFunding_instruments(); - $this->assertEquals(CreditCardTokenTest::$creditCardId, $fi[0]->getCredit_card_token()->getCredit_card_id()); + $fi = $this->payer->getFundingInstruments(); + $this->assertEquals(CreditCardTokenTest::$creditCardId, $fi[0]->getCreditCardToken()->getCreditCardId()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/PaymentHistoryTest.php b/tests/PayPal/Test/Api/PaymentHistoryTest.php index 98885da..577d282 100644 --- a/tests/PayPal/Test/Api/PaymentHistoryTest.php +++ b/tests/PayPal/Test/Api/PaymentHistoryTest.php @@ -15,7 +15,7 @@ class PaymentHistoryTest extends \PHPUnit_Framework_TestCase { public static function createPaymentHistory() { $history = new PaymentHistory(); $history->setCount(self::$count); - $history->setNext_id(self::$nextId); + $history->setNextId(self::$nextId); $history->setPayments(array(PaymentTest::createPayment())); return $history; } @@ -25,7 +25,7 @@ class PaymentHistoryTest extends \PHPUnit_Framework_TestCase { public function testGetterSetters() { $this->assertEquals(self::$count, $this->history->getCount()); - $this->assertEquals(self::$nextId, $this->history->getNext_id()); + $this->assertEquals(self::$nextId, $this->history->getNextId()); } diff --git a/tests/PayPal/Test/Api/PaymentTest.php b/tests/PayPal/Test/Api/PaymentTest.php index 5bdaf31..2bf9795 100644 --- a/tests/PayPal/Test/Api/PaymentTest.php +++ b/tests/PayPal/Test/Api/PaymentTest.php @@ -1,10 +1,6 @@ setReturn_url("http://localhost/return"); - $redirectUrls->setCancel_url("http://localhost/cancel"); + $redirectUrls->setReturnUrl("http://localhost/return"); + $redirectUrls->setCancelUrl("http://localhost/cancel"); $payment = new Payment(); $payment->setIntent("sale"); - $payment->setRedirect_urls($redirectUrls); + $payment->setRedirectUrls($redirectUrls); $payment->setPayer(PayerTest::createPayer()); $payment->setTransactions(array(TransactionTest::createTransaction())); @@ -35,20 +31,20 @@ class PaymentTest extends \PHPUnit_Framework_TestCase { public static function createNewPayment() { $payer = new Payer(); - $payer->setPayment_method("credit_card"); - $payer->setFunding_instruments(array(FundingInstrumentTest::createFundingInstrument())); + $payer->setPaymentMethod("credit_card"); + $payer->setFundingInstruments(array(FundingInstrumentTest::createFundingInstrument())); $transaction = new Transaction(); $transaction->setAmount(AmountTest::createAmount()); $transaction->setDescription("This is the payment description."); $redirectUrls = new RedirectUrls(); - $redirectUrls->setReturn_url("http://localhost/return"); - $redirectUrls->setCancel_url("http://localhost/cancel"); + $redirectUrls->setReturnUrl("http://localhost/return"); + $redirectUrls->setCancelUrl("http://localhost/cancel"); $payment = new Payment(); $payment->setIntent("sale"); - $payment->setRedirect_urls($redirectUrls); + $payment->setRedirectUrls($redirectUrls); $payment->setPayer($payer); $payment->setTransactions(array($transaction)); diff --git a/tests/PayPal/Test/Api/RefundTest.php b/tests/PayPal/Test/Api/RefundTest.php index 9a0387e..657e167 100644 --- a/tests/PayPal/Test/Api/RefundTest.php +++ b/tests/PayPal/Test/Api/RefundTest.php @@ -10,19 +10,17 @@ class RefundTest extends \PHPUnit_Framework_TestCase { public static $captureId = "CAP-123"; public static $createTime = "2013-02-28T00:00:00Z"; - public static $description = "Test refund"; public static $id = "R-5678"; public static $parentPayment = "PAY-123"; public static function createRefund() { $refund = new Refund(); + $refund->setCreateTime(self::$createTime); $refund->setAmount(AmountTest::createAmount()); - $refund->setCapture_id(self::$captureId); - $refund->setCreate_time(self::$createTime); - $refund->setDescription(self::$description); + $refund->setCaptureId(self::$captureId); $refund->setId(self::$id); - $refund->setLinks(array(LinkTest::createLink())); - $refund->setParent_payment(self::$parentPayment); + $refund->setLinks(array(LinksTest::createLinks())); + $refund->setParentPayment(self::$parentPayment); return $refund; } @@ -32,14 +30,13 @@ class RefundTest extends \PHPUnit_Framework_TestCase { } public function testGetterSetter() { - $this->assertEquals(self::$captureId, $this->refund->getCapture_id()); - $this->assertEquals(self::$createTime, $this->refund->getCreate_time()); - $this->assertEquals(self::$description, $this->refund->getDescription()); + $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->getParent_payment()); + $this->assertEquals(self::$parentPayment, $this->refund->getParentPayment()); $this->assertEquals(AmountTest::$currency, $this->refund->getAmount()->getCurrency()); $links = $this->refund->getLinks(); - $this->assertEquals(LinkTest::$href, $links[0]->getHref()); + $this->assertEquals(LinksTest::$href, $links[0]->getHref()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/RelatedResourcesTest.php b/tests/PayPal/Test/Api/RelatedResourcesTest.php new file mode 100644 index 0000000..c977395 --- /dev/null +++ b/tests/PayPal/Test/Api/RelatedResourcesTest.php @@ -0,0 +1,35 @@ +setAuthorization(AuthorizationTest::createAuthorization()); + $relatedResources->setCapture(CaptureTest::createCapture()); + return $relatedResources; + } + + public function setup() { + $this->relatedResources = self::createRelatedResources(); + } + + public function testGetterSetter() { + $this->assertEquals(AuthorizationTest::$create_time, $this->relatedResources->getAuthorization()->getCreateTime()); + $this->assertEquals(CaptureTest::$create_time, $this->relatedResources->getCapture()->getCreateTime()); + } + + public function testSerializeDeserialize() { + $s1 = $this->relatedResources; + + $s2 = new RelatedResources(); + $s2->fromJson($s1->toJson()); + + $this->assertEquals($s1, $s2); + } +} \ No newline at end of file diff --git a/tests/PayPal/Test/Api/SaleTest.php b/tests/PayPal/Test/Api/SaleTest.php index fb46f74..b4c6972 100644 --- a/tests/PayPal/Test/Api/SaleTest.php +++ b/tests/PayPal/Test/Api/SaleTest.php @@ -6,7 +6,7 @@ use PayPal\Api\Sale; use PayPal\Test\Constants; use PayPal\Test\Api\AmountTest; use PayPal\Test\Api\PaymentTest; -use PayPal\Test\Api\LinkTest; +use PayPal\Test\Api\LinksTest; class SaleTest extends \PHPUnit_Framework_TestCase { @@ -14,7 +14,6 @@ class SaleTest extends \PHPUnit_Framework_TestCase { public static $captureId = "CAP-123"; public static $createTime = "2013-02-28T00:00:00Z"; - public static $description = "Test refund"; public static $id = "R-5678"; public static $parentPayment = "PAY-123"; public static $state = "Created"; @@ -22,10 +21,10 @@ class SaleTest extends \PHPUnit_Framework_TestCase { public static function createSale() { $sale = new Sale(); $sale->setAmount(AmountTest::createAmount()); - $sale->setCreate_time(self::$createTime); + $sale->setCreateTime(self::$createTime); $sale->setId(self::$id); - $sale->setLinks(array(LinkTest::createLink())); - $sale->setParent_payment(self::$parentPayment); + $sale->setLinks(array(LinksTest::createLinks())); + $sale->setParentPayment(self::$parentPayment); $sale->setState(self::$state); return $sale; } @@ -35,13 +34,13 @@ class SaleTest extends \PHPUnit_Framework_TestCase { } public function testGetterSetter() { - $this->assertEquals(self::$createTime, $this->sale->getCreate_time()); + $this->assertEquals(self::$createTime, $this->sale->getCreateTime()); $this->assertEquals(self::$id, $this->sale->getId()); - $this->assertEquals(self::$parentPayment, $this->sale->getParent_payment()); + $this->assertEquals(self::$parentPayment, $this->sale->getParentPayment()); $this->assertEquals(self::$state, $this->sale->getState()); $this->assertEquals(AmountTest::$currency, $this->sale->getAmount()->getCurrency()); $links = $this->sale->getLinks(); - $this->assertEquals(LinkTest::$href, $links[0]->getHref()); + $this->assertEquals(LinksTest::$href, $links[0]->getHref()); } public function testSerializeDeserialize() { @@ -58,7 +57,7 @@ class SaleTest extends \PHPUnit_Framework_TestCase { $payment->create(); $transactions = $payment->getTransactions(); - $resources = $transactions[0]->getRelated_resources(); + $resources = $transactions[0]->getRelatedResources(); $saleId = $resources[0]->getSale()->getId(); $sale = Sale::get($saleId); diff --git a/tests/PayPal/Test/Api/ShippingAddressTest.php b/tests/PayPal/Test/Api/ShippingAddressTest.php index 4560ae1..6ca8b93 100644 --- a/tests/PayPal/Test/Api/ShippingAddressTest.php +++ b/tests/PayPal/Test/Api/ShippingAddressTest.php @@ -16,7 +16,6 @@ class ShippingAddressTest extends \PHPUnit_Framework_TestCase { public static $countryCode = "US"; public static $phone = "716-298-1822"; public static $recipientName = "TestUser"; - public static $type = "Billing"; public static function createAddress() { $addr = new ShippingAddress(); @@ -24,11 +23,10 @@ class ShippingAddressTest extends \PHPUnit_Framework_TestCase { $addr->setLine2(self::$line2); $addr->setCity(self::$city); $addr->setState(self::$state); - $addr->setPostal_code(self::$postalCode); - $addr->setCountry_code(self::$countryCode); + $addr->setPostalCode(self::$postalCode); + $addr->setCountryCode(self::$countryCode); $addr->setPhone(self::$phone); - $addr->setRecipient_name(self::$recipientName); - $addr->setType(self::$type); + $addr->setRecipientName(self::$recipientName); return $addr; } @@ -41,11 +39,10 @@ class ShippingAddressTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(self::$line2, $this->address->getLine2()); $this->assertEquals(self::$city, $this->address->getCity()); $this->assertEquals(self::$state, $this->address->getState()); - $this->assertEquals(self::$postalCode, $this->address->getPostal_code()); - $this->assertEquals(self::$countryCode, $this->address->getCountry_code()); + $this->assertEquals(self::$postalCode, $this->address->getPostalCode()); + $this->assertEquals(self::$countryCode, $this->address->getCountryCode()); $this->assertEquals(self::$phone, $this->address->getPhone()); - $this->assertEquals(self::$recipientName, $this->address->getRecipient_name()); - $this->assertEquals(self::$type, $this->address->getType()); + $this->assertEquals(self::$recipientName, $this->address->getRecipientName()); } public function testSerializeDeserialize() { diff --git a/tests/PayPal/Test/Api/SubTransactionTest.php b/tests/PayPal/Test/Api/SubTransactionTest.php deleted file mode 100644 index 7d57496..0000000 --- a/tests/PayPal/Test/Api/SubTransactionTest.php +++ /dev/null @@ -1,35 +0,0 @@ -setAuthorization(AuthorizationTest::createAuthorization()); - $subTransaction->setCapture(CaptureTest::createCapture()); - return $subTransaction; - } - - public function setup() { - $this->subTransaction = self::createSubTransaction(); - } - - public function testGetterSetter() { - $this->assertEquals(AuthorizationTest::$create_time, $this->subTransaction->getAuthorization()->getCreate_Time()); - $this->assertEquals(CaptureTest::$create_time, $this->subTransaction->getCapture()->getCreate_Time()); - } - - public function testSerializeDeserialize() { - $s1 = $this->subTransaction; - - $s2 = new SubTransaction(); - $s2->fromJson($s1->toJson()); - - $this->assertEquals($s1, $s2); - } -} \ No newline at end of file diff --git a/tests/PayPal/Test/Api/TransactionTest.php b/tests/PayPal/Test/Api/TransactionTest.php index d23b281..f2e0ba3 100644 --- a/tests/PayPal/Test/Api/TransactionTest.php +++ b/tests/PayPal/Test/Api/TransactionTest.php @@ -18,9 +18,9 @@ class TransactionTest extends \PHPUnit_Framework_TestCase { $transaction = new Transaction(); $transaction->setAmount(AmountTest::createAmount()); $transaction->setDescription(self::$description); - $transaction->setItem_list(ItemListTest::createItemList()); + $transaction->setItemList(ItemListTest::createItemList()); $transaction->setPayee(PayeeTest::createPayee()); - $transaction->setRelated_resources( array(SubTransactionTest::createSubTransaction()) ); + $transaction->setRelatedResources( array(RelatedResourcesTest::createRelatedResources()) ); return $transaction; } @@ -31,11 +31,11 @@ class TransactionTest extends \PHPUnit_Framework_TestCase { public function testGetterSetter() { $this->assertEquals(AmountTest::$currency, $this->transaction->getAmount()->getCurrency()); $this->assertEquals(self::$description, $this->transaction->getDescription()); - $items = $this->transaction->getItem_list()->getItems(); + $items = $this->transaction->getItemList()->getItems(); $this->assertEquals(ItemTest::$quantity, $items[0]->getQuantity()); $this->assertEquals(PayeeTest::$email, $this->transaction->getPayee()->getEmail()); - $resources = $this->transaction->getRelated_resources(); - $this->assertEquals(AuthorizationTest::$create_time, $resources[0]->getAuthorization()->getCreate_Time()); + $resources = $this->transaction->getRelatedResources(); + $this->assertEquals(AuthorizationTest::$create_time, $resources[0]->getAuthorization()->getCreateTime()); } public function testSerializeDeserialize() {