forked from LiveCarta/PayPal-PHP-SDK
testcases updated
updated testcases to match new json schema and updates with camel case function names
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Api\AmountDetails;
|
||||
use PayPal\Api\Details;
|
||||
use PayPal\Test\Constants;
|
||||
|
||||
class AmountDetailsTest extends \PHPUnit_Framework_TestCase {
|
||||
class DetailsTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
private $amountDetails;
|
||||
|
||||
@@ -14,7 +14,7 @@ class AmountDetailsTest extends \PHPUnit_Framework_TestCase {
|
||||
public static $fee = "4.99";
|
||||
|
||||
public static function createAmountDetails() {
|
||||
$amountDetails = new AmountDetails();
|
||||
$amountDetails = new Details();
|
||||
$amountDetails->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);
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Api\Link;
|
||||
use PayPal\Test\Constants;
|
||||
|
||||
class LinkTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
private $link;
|
||||
|
||||
public static $href = "USD";
|
||||
public static $rel = "1.12";
|
||||
public static $method = "1.12";
|
||||
|
||||
public static function createLink() {
|
||||
$link = new Link();
|
||||
$link->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);
|
||||
}
|
||||
}
|
||||
40
tests/PayPal/Test/Api/LinksTest.php
Normal file
40
tests/PayPal/Test/Api/LinksTest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Api\Links;
|
||||
use PayPal\Test\Constants;
|
||||
|
||||
class LinksTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
private $links;
|
||||
|
||||
public static $href = "USD";
|
||||
public static $rel = "1.12";
|
||||
public static $method = "1.12";
|
||||
|
||||
public static function createLinks() {
|
||||
$links = new Links();
|
||||
$links->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);
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
|
||||
use PayPal\Api\RedirectUrls;
|
||||
|
||||
use PayPal\Api\Address;
|
||||
use PayPal\Api\Amount;
|
||||
use PayPal\Api\CreditCard;
|
||||
@@ -21,12 +17,12 @@ class PaymentTest extends \PHPUnit_Framework_TestCase {
|
||||
public static function createPayment() {
|
||||
|
||||
$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(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));
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
35
tests/PayPal/Test/Api/RelatedResourcesTest.php
Normal file
35
tests/PayPal/Test/Api/RelatedResourcesTest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Api\RelatedResources;
|
||||
use PayPal\Test\Constants;
|
||||
|
||||
class RelatedResourcesTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
private $RelatedResources;
|
||||
|
||||
public static function createRelatedResources() {
|
||||
$relatedResources = new RelatedResources();
|
||||
$relatedResources->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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
namespace PayPal\Test\Api;
|
||||
|
||||
use PayPal\Api\SubTransaction;
|
||||
use PayPal\Test\Constants;
|
||||
|
||||
class SubTransactionTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
private $subTransaction;
|
||||
|
||||
public static function createSubTransaction() {
|
||||
$subTransaction = new SubTransaction();
|
||||
$subTransaction->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);
|
||||
}
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user