testcases updated

updated testcases to match new json schema
and updates with camel case function names
This commit is contained in:
Ganesh Hegde
2013-05-28 10:08:34 +05:30
parent 125a7b66f3
commit 50b09bdbde
22 changed files with 179 additions and 197 deletions

View File

@@ -23,10 +23,9 @@ class AddressTest extends \PHPUnit_Framework_TestCase {
$addr->setLine2(self::$line2); $addr->setLine2(self::$line2);
$addr->setCity(self::$city); $addr->setCity(self::$city);
$addr->setState(self::$state); $addr->setState(self::$state);
$addr->setPostal_code(self::$postalCode); $addr->setPostalCode(self::$postalCode);
$addr->setCountry_code(self::$countryCode); $addr->setCountryCode(self::$countryCode);
$addr->setPhone(self::$phone); $addr->setPhone(self::$phone);
$addr->setType(self::$type);
return $addr; return $addr;
} }
@@ -39,10 +38,9 @@ class AddressTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals(self::$line2, $this->address->getLine2()); $this->assertEquals(self::$line2, $this->address->getLine2());
$this->assertEquals(self::$city, $this->address->getCity()); $this->assertEquals(self::$city, $this->address->getCity());
$this->assertEquals(self::$state, $this->address->getState()); $this->assertEquals(self::$state, $this->address->getState());
$this->assertEquals(self::$postalCode, $this->address->getPostal_code()); $this->assertEquals(self::$postalCode, $this->address->getPostalCode());
$this->assertEquals(self::$countryCode, $this->address->getCountry_code()); $this->assertEquals(self::$countryCode, $this->address->getCountryCode());
$this->assertEquals(self::$phone, $this->address->getPhone()); $this->assertEquals(self::$phone, $this->address->getPhone());
$this->assertEquals(self::$type, $this->address->getType());
} }
public function testSerializeDeserialize() { public function testSerializeDeserialize() {

View File

@@ -24,14 +24,14 @@ class AmountTest extends \PHPUnit_Framework_TestCase {
$this->amounts['partial'] = self::createAmount(); $this->amounts['partial'] = self::createAmount();
$amount = self::createAmount(); $amount = self::createAmount();
$amount->setDetails(AmountDetailsTest::createAmountDetails()); $amount->setDetails(DetailsTest::createAmountDetails());
$this->amounts['full'] = $amount; $this->amounts['full'] = $amount;
} }
public function testGetterSetter() { public function testGetterSetter() {
$this->assertEquals(self::$currency, $this->amounts['partial']->getCurrency()); $this->assertEquals(self::$currency, $this->amounts['partial']->getCurrency());
$this->assertEquals(self::$total, $this->amounts['partial']->getTotal()); $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() { public function testSerializeDeserialize() {

View File

@@ -3,7 +3,7 @@ namespace PayPal\Test\Api;
use PayPal\Api\Amount; use PayPal\Api\Amount;
use PayPal\Api\Authorization; use PayPal\Api\Authorization;
use PayPal\Api\Link; use PayPal\Api\Links;
use PayPal\Test\Constants; use PayPal\Test\Constants;
class AuthorizationTest extends \PHPUnit_Framework_TestCase { class AuthorizationTest extends \PHPUnit_Framework_TestCase {
@@ -24,22 +24,22 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase {
public static function createAuthorization() { public static function createAuthorization() {
$authorization = new Authorization(); $authorization = new Authorization();
$authorization->setCreate_time(self::$create_time); $authorization->setCreateTime(self::$create_time);
$authorization->setId(self::$id); $authorization->setId(self::$id);
$authorization->setState(self::$state); $authorization->setState(self::$state);
$authorization->setAmount(AmountTest::createAmount()); $authorization->setAmount(AmountTest::createAmount());
$authorization->setLinks(array(LinkTest::createLink())); $authorization->setLinks(array(LinksTest::createLinks()));
return $authorization; return $authorization;
} }
public function setup() { public function setup() {
$authorization = new Authorization(); $authorization = new Authorization();
$authorization->setCreate_time(self::$create_time); $authorization->setCreateTime(self::$create_time);
$authorization->setId(self::$id); $authorization->setId(self::$id);
$authorization->setState(self::$state); $authorization->setState(self::$state);
$authorization->setParent_payment(self::$parent_payment); $authorization->setParentPayment(self::$parent_payment);
$this->authorizations['partial'] = $authorization; $this->authorizations['partial'] = $authorization;
@@ -48,10 +48,10 @@ class AuthorizationTest extends \PHPUnit_Framework_TestCase {
public function testGetterSetter() { public function testGetterSetter() {
$authorization = $this->authorizations['partial']; $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::$id, $authorization->getId());
$this->assertEquals(self::$state, $authorization->getState()); $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']; $authorization = $this->authorizations['full'];
$this->assertEquals(AmountTest::$currency, $authorization->getAmount()->getCurrency()); $this->assertEquals(AmountTest::$currency, $authorization->getAmount()->getCurrency());

View File

@@ -10,18 +10,15 @@ class CaptureTest extends \PHPUnit_Framework_TestCase {
public static $authorization_id = "AUTH-123"; public static $authorization_id = "AUTH-123";
public static $create_time = "2013-02-28T00:00:00Z"; public static $create_time = "2013-02-28T00:00:00Z";
public static $description = "Test capture";
public static $id = "C-5678"; public static $id = "C-5678";
public static $parent_payment = "PAY-123"; public static $parent_payment = "PAY-123";
public static $state = "Created"; public static $state = "Created";
public static function createCapture() { public static function createCapture() {
$capture = new Capture(); $capture = new Capture();
$capture->setAuthorization_id(self::$authorization_id); $capture->setCreateTime(self::$create_time);
$capture->setCreate_time(self::$create_time);
$capture->setDescription(self::$description);
$capture->setId(self::$id); $capture->setId(self::$id);
$capture->setParent_payment(self::$parent_payment); $capture->setParentPayment(self::$parent_payment);
$capture->setState(self::$state); $capture->setState(self::$state);
return $capture; return $capture;
@@ -32,21 +29,19 @@ class CaptureTest extends \PHPUnit_Framework_TestCase {
$capture = self::createCapture(); $capture = self::createCapture();
$capture->setAmount(AmountTest::createAmount()); $capture->setAmount(AmountTest::createAmount());
$capture->setLinks(array(LinkTest::createLink())); $capture->setLinks(array(LinksTest::createLinks()));
$this->captures['full'] = $capture; $this->captures['full'] = $capture;
} }
public function testGetterSetter() { public function testGetterSetter() {
$this->assertEquals(self::$authorization_id, $this->captures['partial']->getAuthorization_id()); $this->assertEquals(self::$create_time, $this->captures['partial']->getCreateTime());
$this->assertEquals(self::$create_time, $this->captures['partial']->getCreate_time());
$this->assertEquals(self::$description, $this->captures['partial']->getDescription());
$this->assertEquals(self::$id, $this->captures['partial']->getId()); $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(self::$state, $this->captures['partial']->getState());
$this->assertEquals(AmountTest::$currency, $this->captures['full']->getAmount()->getCurrency()); $this->assertEquals(AmountTest::$currency, $this->captures['full']->getAmount()->getCurrency());
$links = $this->captures['full']->getLinks(); $links = $this->captures['full']->getLinks();
$this->assertEquals(LinkTest::$href, $links[0]->getHref()); $this->assertEquals(LinksTest::$href, $links[0]->getHref());
} }
public function testSerializeDeserialize() { public function testSerializeDeserialize() {

View File

@@ -26,23 +26,23 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase {
$card = new CreditCard(); $card = new CreditCard();
$card->setType(self::$cardType); $card->setType(self::$cardType);
$card->setNumber(self::$cardNumber); $card->setNumber(self::$cardNumber);
$card->setExpire_month(self::$expireMonth); $card->setExpireMonth(self::$expireMonth);
$card->setExpire_year(self::$expireYear); $card->setExpireYear(self::$expireYear);
$card->setCvv2(self::$cvv); $card->setCvv2(self::$cvv);
$card->setFirst_name(self::$firstName); $card->setFirstName(self::$firstName);
$card->setLast_name(self::$lastName); $card->setLastName(self::$lastName);
$card->setId(self::$id); $card->setId(self::$id);
$card->setValid_until(self::$validUntil); $card->setValidUntil(self::$validUntil);
$card->setState(self::$state); $card->setState(self::$state);
$card->setPayer_id(self::$payerId); $card->setPayerId(self::$payerId);
return $card; return $card;
} }
public function setup() { public function setup() {
$card = self::createCreditCard(); $card = self::createCreditCard();
$card->setBilling_address(AddressTest::createAddress()); $card->setBillingAddress(AddressTest::createAddress());
$card->setLinks(array(LinkTest::createLink())); $card->setLinks(array(LinksTest::createLinks()));
$this->cards['full'] = $card; $this->cards['full'] = $card;
$card = self::createCreditCard(); $card = self::createCreditCard();
@@ -53,20 +53,20 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase {
$c = $this->cards['partial']; $c = $this->cards['partial'];
$this->assertEquals(self::$cardType, $c->getType()); $this->assertEquals(self::$cardType, $c->getType());
$this->assertEquals(self::$cardNumber, $c->getNumber()); $this->assertEquals(self::$cardNumber, $c->getNumber());
$this->assertEquals(self::$expireMonth, $c->getExpire_month()); $this->assertEquals(self::$expireMonth, $c->getExpireMonth());
$this->assertEquals(self::$expireYear, $c->getExpire_year()); $this->assertEquals(self::$expireYear, $c->getExpireYear());
$this->assertEquals(self::$cvv, $c->getCvv2()); $this->assertEquals(self::$cvv, $c->getCvv2());
$this->assertEquals(self::$firstName, $c->getFirst_name()); $this->assertEquals(self::$firstName, $c->getFirstName());
$this->assertEquals(self::$lastName, $c->getLast_name()); $this->assertEquals(self::$lastName, $c->getLastName());
$this->assertEquals(self::$id, $c->getId()); $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::$state, $c->getState());
$this->assertEquals(self::$payerId, $c->getPayer_id()); $this->assertEquals(self::$payerId, $c->getPayerId());
$c = $this->cards['full']; $c = $this->cards['full'];
$this->assertEquals(AddressTest::$line1, $c->getBilling_address()->getLine1()); $this->assertEquals(AddressTest::$line1, $c->getBillingAddress()->getLine1());
$link = $c->getLinks(); $link = $c->getLinks();
$this->assertEquals(LinkTest::$href, $link[0]->getHref()); $this->assertEquals(LinksTest::$href, $link[0]->getHref());
} }
public function testSerializeDeserialize() { public function testSerializeDeserialize() {
@@ -87,7 +87,7 @@ class CreditCardTest extends \PHPUnit_Framework_TestCase {
$this->assertNotNull($c1->getId()); $this->assertNotNull($c1->getId());
$c2 = CreditCard::get($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->assertGreaterThan(0, count($c2->getLinks()));
$this->assertEquals(self::$cardType, $c2->getType()); $this->assertEquals(self::$cardType, $c2->getType());
$this->assertNotNull($c2->getState()); $this->assertNotNull($c2->getState());

View File

@@ -13,8 +13,8 @@ class CreditCardTokenTest extends \PHPUnit_Framework_TestCase {
public static function createCreditCardToken() { public static function createCreditCardToken() {
$ccToken = new CreditCardToken(); $ccToken = new CreditCardToken();
$ccToken->setPayer_id(self::$payerId); $ccToken->setPayerId(self::$payerId);
$ccToken->setCredit_card_id(self::$creditCardId); $ccToken->setCreditCardId(self::$creditCardId);
return $ccToken; return $ccToken;
} }
@@ -23,8 +23,8 @@ class CreditCardTokenTest extends \PHPUnit_Framework_TestCase {
} }
public function testGetterSetter() { public function testGetterSetter() {
$this->assertEquals(self::$payerId, $this->ccToken->getPayer_id()); $this->assertEquals(self::$payerId, $this->ccToken->getPayerId());
$this->assertEquals(self::$creditCardId, $this->ccToken->getCredit_card_id()); $this->assertEquals(self::$creditCardId, $this->ccToken->getCreditCardId());
} }
public function testSerializeDeserialize() { public function testSerializeDeserialize() {

View File

@@ -1,10 +1,10 @@
<?php <?php
namespace PayPal\Test\Api; namespace PayPal\Test\Api;
use PayPal\Api\AmountDetails; use PayPal\Api\Details;
use PayPal\Test\Constants; use PayPal\Test\Constants;
class AmountDetailsTest extends \PHPUnit_Framework_TestCase { class DetailsTest extends \PHPUnit_Framework_TestCase {
private $amountDetails; private $amountDetails;
@@ -14,7 +14,7 @@ class AmountDetailsTest extends \PHPUnit_Framework_TestCase {
public static $fee = "4.99"; public static $fee = "4.99";
public static function createAmountDetails() { public static function createAmountDetails() {
$amountDetails = new AmountDetails(); $amountDetails = new Details();
$amountDetails->setSubtotal(self::$subtotal); $amountDetails->setSubtotal(self::$subtotal);
$amountDetails->setTax(self::$tax); $amountDetails->setTax(self::$tax);
$amountDetails->setShipping(self::$shipping); $amountDetails->setShipping(self::$shipping);
@@ -37,7 +37,7 @@ class AmountDetailsTest extends \PHPUnit_Framework_TestCase {
public function testSerializeDeserialize() { public function testSerializeDeserialize() {
$a1 = $this->amountDetails; $a1 = $this->amountDetails;
$a2 = new AmountDetails(); $a2 = new Details();
$a2->fromJson($a1->toJson()); $a2->fromJson($a1->toJson());
$this->assertEquals($a1, $a2); $this->assertEquals($a1, $a2);

View File

@@ -11,8 +11,8 @@ class FundingInstrumentTest extends \PHPUnit_Framework_TestCase {
public static function createFundingInstrument() { public static function createFundingInstrument() {
$fi = new FundingInstrument(); $fi = new FundingInstrument();
$fi->setCredit_card(CreditCardTest::createCreditCard()); $fi->setCreditCard(CreditCardTest::createCreditCard());
$fi->setCredit_card_token(CreditCardTokenTest::createCreditCardToken()); $fi->setCreditCardToken(CreditCardTokenTest::createCreditCardToken());
return $fi; return $fi;
} }
@@ -21,9 +21,9 @@ class FundingInstrumentTest extends \PHPUnit_Framework_TestCase {
} }
public function testGetterSetter() { 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->assertEquals(CreditCardTokenTest::$creditCardId,
$this->fi->getCredit_card_token()->getCredit_card_id()); $this->fi->getCreditCardToken()->getCreditCardId());
} }
public function testSerializeDeserialize() { public function testSerializeDeserialize() {

View File

@@ -21,7 +21,7 @@ class ItemListTest extends \PHPUnit_Framework_TestCase {
$itemList = new ItemList(); $itemList = new ItemList();
$itemList->setItems(array($item)); $itemList->setItems(array($item));
$itemList->setShipping_address(ShippingAddressTest::createAddress()); $itemList->setShippingAddress(ShippingAddressTest::createAddress());
return $itemList; return $itemList;
} }
@@ -33,7 +33,7 @@ class ItemListTest extends \PHPUnit_Framework_TestCase {
public function testGetterSetters() { public function testGetterSetters() {
$items = $this->items->getItems(); $items = $this->items->getItems();
$this->assertEquals(ItemTest::createItem(), $items[0]); $this->assertEquals(ItemTest::createItem(), $items[0]);
$this->assertEquals(ShippingAddressTest::createAddress(), $this->items->getShipping_address()); $this->assertEquals(ShippingAddressTest::createAddress(), $this->items->getShippingAddress());
} }
public function testSerializeDeserialize() { public function testSerializeDeserialize() {

View File

@@ -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);
}
}

View 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);
}
}

View File

@@ -17,7 +17,7 @@ class PayeeTest extends \PHPUnit_Framework_TestCase {
public static function createPayee() { public static function createPayee() {
$payee = new Payee(); $payee = new Payee();
$payee->setEmail(self::$email); $payee->setEmail(self::$email);
$payee->setMerchant_id(self::$merchant_id); $payee->setMerchantId(self::$merchant_id);
$payee->setPhone(self::$phone); $payee->setPhone(self::$phone);
return $payee; return $payee;
@@ -29,7 +29,7 @@ class PayeeTest extends \PHPUnit_Framework_TestCase {
public function testGetterSetter() { public function testGetterSetter() {
$this->assertEquals(self::$email, $this->payee->getEmail()); $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()); $this->assertEquals(self::$phone, $this->payee->getPhone());
} }

View File

@@ -17,11 +17,11 @@ class PayerInfoTest extends \PHPUnit_Framework_TestCase {
public static function createPayerInfo() { public static function createPayerInfo() {
$payerInfo = new PayerInfo(); $payerInfo = new PayerInfo();
$payerInfo->setEmail(self::$email); $payerInfo->setEmail(self::$email);
$payerInfo->setFirst_name(self::$firstName); $payerInfo->setFirstName(self::$firstName);
$payerInfo->setLast_name(self::$lastName); $payerInfo->setLastName(self::$lastName);
$payerInfo->setPhone(self::$phone); $payerInfo->setPhone(self::$phone);
$payerInfo->setPayer_id(self::$payerId); $payerInfo->setPayerId(self::$payerId);
$payerInfo->setShipping_address(AddressTest::createAddress()); $payerInfo->setShippingAddress(AddressTest::createAddress());
return $payerInfo; return $payerInfo;
} }
@@ -32,11 +32,11 @@ class PayerInfoTest extends \PHPUnit_Framework_TestCase {
public function testGetterSetter() { public function testGetterSetter() {
$this->assertEquals(self::$email, $this->payerInfo->getEmail()); $this->assertEquals(self::$email, $this->payerInfo->getEmail());
$this->assertEquals(self::$firstName, $this->payerInfo->getFirst_name()); $this->assertEquals(self::$firstName, $this->payerInfo->getFirstName());
$this->assertEquals(self::$lastName, $this->payerInfo->getLast_name()); $this->assertEquals(self::$lastName, $this->payerInfo->getLastName());
$this->assertEquals(self::$phone, $this->payerInfo->getPhone()); $this->assertEquals(self::$phone, $this->payerInfo->getPhone());
$this->assertEquals(self::$payerId, $this->payerInfo->getPayer_id()); $this->assertEquals(self::$payerId, $this->payerInfo->getPayerId());
$this->assertEquals(AddressTest::$line1, $this->payerInfo->getShipping_address()->getLine1()); $this->assertEquals(AddressTest::$line1, $this->payerInfo->getShippingAddress()->getLine1());
} }
public function testSerializeDeserialize() { public function testSerializeDeserialize() {

View File

@@ -15,9 +15,9 @@ class PayerTest extends \PHPUnit_Framework_TestCase {
public static function createPayer() { public static function createPayer() {
$payer = new Payer(); $payer = new Payer();
$payer->setPayment_method(self::$paymentMethod); $payer->setPaymentMethod(self::$paymentMethod);
$payer->setPayer_info(PayerInfoTest::createPayerInfo()); $payer->setPayerInfo(PayerInfoTest::createPayerInfo());
$payer->setFunding_instruments(array(FundingInstrumentTest::createFundingInstrument())); $payer->setFundingInstruments(array(FundingInstrumentTest::createFundingInstrument()));
return $payer; return $payer;
} }
@@ -27,11 +27,11 @@ class PayerTest extends \PHPUnit_Framework_TestCase {
} }
public function testGetterSetter() { public function testGetterSetter() {
$this->assertEquals(self::$paymentMethod, $this->payer->getPayment_method()); $this->assertEquals(self::$paymentMethod, $this->payer->getPaymentMethod());
$this->assertEquals(PayerInfoTest::$email, $this->payer->getPayer_info()->getEmail()); $this->assertEquals(PayerInfoTest::$email, $this->payer->getPayerInfo()->getEmail());
$fi = $this->payer->getFunding_instruments(); $fi = $this->payer->getFundingInstruments();
$this->assertEquals(CreditCardTokenTest::$creditCardId, $fi[0]->getCredit_card_token()->getCredit_card_id()); $this->assertEquals(CreditCardTokenTest::$creditCardId, $fi[0]->getCreditCardToken()->getCreditCardId());
} }
public function testSerializeDeserialize() { public function testSerializeDeserialize() {

View File

@@ -15,7 +15,7 @@ class PaymentHistoryTest extends \PHPUnit_Framework_TestCase {
public static function createPaymentHistory() { public static function createPaymentHistory() {
$history = new PaymentHistory(); $history = new PaymentHistory();
$history->setCount(self::$count); $history->setCount(self::$count);
$history->setNext_id(self::$nextId); $history->setNextId(self::$nextId);
$history->setPayments(array(PaymentTest::createPayment())); $history->setPayments(array(PaymentTest::createPayment()));
return $history; return $history;
} }
@@ -25,7 +25,7 @@ class PaymentHistoryTest extends \PHPUnit_Framework_TestCase {
public function testGetterSetters() { public function testGetterSetters() {
$this->assertEquals(self::$count, $this->history->getCount()); $this->assertEquals(self::$count, $this->history->getCount());
$this->assertEquals(self::$nextId, $this->history->getNext_id()); $this->assertEquals(self::$nextId, $this->history->getNextId());
} }

View File

@@ -1,10 +1,6 @@
<?php <?php
namespace PayPal\Test\Api; namespace PayPal\Test\Api;
use PayPal\Api\RedirectUrls; use PayPal\Api\RedirectUrls;
use PayPal\Api\Address; use PayPal\Api\Address;
use PayPal\Api\Amount; use PayPal\Api\Amount;
use PayPal\Api\CreditCard; use PayPal\Api\CreditCard;
@@ -21,12 +17,12 @@ class PaymentTest extends \PHPUnit_Framework_TestCase {
public static function createPayment() { public static function createPayment() {
$redirectUrls = new RedirectUrls(); $redirectUrls = new RedirectUrls();
$redirectUrls->setReturn_url("http://localhost/return"); $redirectUrls->setReturnUrl("http://localhost/return");
$redirectUrls->setCancel_url("http://localhost/cancel"); $redirectUrls->setCancelUrl("http://localhost/cancel");
$payment = new Payment(); $payment = new Payment();
$payment->setIntent("sale"); $payment->setIntent("sale");
$payment->setRedirect_urls($redirectUrls); $payment->setRedirectUrls($redirectUrls);
$payment->setPayer(PayerTest::createPayer()); $payment->setPayer(PayerTest::createPayer());
$payment->setTransactions(array(TransactionTest::createTransaction())); $payment->setTransactions(array(TransactionTest::createTransaction()));
@@ -35,20 +31,20 @@ class PaymentTest extends \PHPUnit_Framework_TestCase {
public static function createNewPayment() { public static function createNewPayment() {
$payer = new Payer(); $payer = new Payer();
$payer->setPayment_method("credit_card"); $payer->setPaymentMethod("credit_card");
$payer->setFunding_instruments(array(FundingInstrumentTest::createFundingInstrument())); $payer->setFundingInstruments(array(FundingInstrumentTest::createFundingInstrument()));
$transaction = new Transaction(); $transaction = new Transaction();
$transaction->setAmount(AmountTest::createAmount()); $transaction->setAmount(AmountTest::createAmount());
$transaction->setDescription("This is the payment description."); $transaction->setDescription("This is the payment description.");
$redirectUrls = new RedirectUrls(); $redirectUrls = new RedirectUrls();
$redirectUrls->setReturn_url("http://localhost/return"); $redirectUrls->setReturnUrl("http://localhost/return");
$redirectUrls->setCancel_url("http://localhost/cancel"); $redirectUrls->setCancelUrl("http://localhost/cancel");
$payment = new Payment(); $payment = new Payment();
$payment->setIntent("sale"); $payment->setIntent("sale");
$payment->setRedirect_urls($redirectUrls); $payment->setRedirectUrls($redirectUrls);
$payment->setPayer($payer); $payment->setPayer($payer);
$payment->setTransactions(array($transaction)); $payment->setTransactions(array($transaction));

View File

@@ -10,19 +10,17 @@ class RefundTest extends \PHPUnit_Framework_TestCase {
public static $captureId = "CAP-123"; public static $captureId = "CAP-123";
public static $createTime = "2013-02-28T00:00:00Z"; public static $createTime = "2013-02-28T00:00:00Z";
public static $description = "Test refund";
public static $id = "R-5678"; public static $id = "R-5678";
public static $parentPayment = "PAY-123"; public static $parentPayment = "PAY-123";
public static function createRefund() { public static function createRefund() {
$refund = new Refund(); $refund = new Refund();
$refund->setCreateTime(self::$createTime);
$refund->setAmount(AmountTest::createAmount()); $refund->setAmount(AmountTest::createAmount());
$refund->setCapture_id(self::$captureId); $refund->setCaptureId(self::$captureId);
$refund->setCreate_time(self::$createTime);
$refund->setDescription(self::$description);
$refund->setId(self::$id); $refund->setId(self::$id);
$refund->setLinks(array(LinkTest::createLink())); $refund->setLinks(array(LinksTest::createLinks()));
$refund->setParent_payment(self::$parentPayment); $refund->setParentPayment(self::$parentPayment);
return $refund; return $refund;
} }
@@ -32,14 +30,13 @@ class RefundTest extends \PHPUnit_Framework_TestCase {
} }
public function testGetterSetter() { public function testGetterSetter() {
$this->assertEquals(self::$captureId, $this->refund->getCapture_id()); $this->assertEquals(self::$captureId, $this->refund->getCaptureId());
$this->assertEquals(self::$createTime, $this->refund->getCreate_time()); $this->assertEquals(self::$createTime, $this->refund->getCreateTime());
$this->assertEquals(self::$description, $this->refund->getDescription());
$this->assertEquals(self::$id, $this->refund->getId()); $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()); $this->assertEquals(AmountTest::$currency, $this->refund->getAmount()->getCurrency());
$links = $this->refund->getLinks(); $links = $this->refund->getLinks();
$this->assertEquals(LinkTest::$href, $links[0]->getHref()); $this->assertEquals(LinksTest::$href, $links[0]->getHref());
} }
public function testSerializeDeserialize() { public function testSerializeDeserialize() {

View 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);
}
}

View File

@@ -6,7 +6,7 @@ use PayPal\Api\Sale;
use PayPal\Test\Constants; use PayPal\Test\Constants;
use PayPal\Test\Api\AmountTest; use PayPal\Test\Api\AmountTest;
use PayPal\Test\Api\PaymentTest; use PayPal\Test\Api\PaymentTest;
use PayPal\Test\Api\LinkTest; use PayPal\Test\Api\LinksTest;
class SaleTest extends \PHPUnit_Framework_TestCase { class SaleTest extends \PHPUnit_Framework_TestCase {
@@ -14,7 +14,6 @@ class SaleTest extends \PHPUnit_Framework_TestCase {
public static $captureId = "CAP-123"; public static $captureId = "CAP-123";
public static $createTime = "2013-02-28T00:00:00Z"; public static $createTime = "2013-02-28T00:00:00Z";
public static $description = "Test refund";
public static $id = "R-5678"; public static $id = "R-5678";
public static $parentPayment = "PAY-123"; public static $parentPayment = "PAY-123";
public static $state = "Created"; public static $state = "Created";
@@ -22,10 +21,10 @@ class SaleTest extends \PHPUnit_Framework_TestCase {
public static function createSale() { public static function createSale() {
$sale = new Sale(); $sale = new Sale();
$sale->setAmount(AmountTest::createAmount()); $sale->setAmount(AmountTest::createAmount());
$sale->setCreate_time(self::$createTime); $sale->setCreateTime(self::$createTime);
$sale->setId(self::$id); $sale->setId(self::$id);
$sale->setLinks(array(LinkTest::createLink())); $sale->setLinks(array(LinksTest::createLinks()));
$sale->setParent_payment(self::$parentPayment); $sale->setParentPayment(self::$parentPayment);
$sale->setState(self::$state); $sale->setState(self::$state);
return $sale; return $sale;
} }
@@ -35,13 +34,13 @@ class SaleTest extends \PHPUnit_Framework_TestCase {
} }
public function testGetterSetter() { 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::$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(self::$state, $this->sale->getState());
$this->assertEquals(AmountTest::$currency, $this->sale->getAmount()->getCurrency()); $this->assertEquals(AmountTest::$currency, $this->sale->getAmount()->getCurrency());
$links = $this->sale->getLinks(); $links = $this->sale->getLinks();
$this->assertEquals(LinkTest::$href, $links[0]->getHref()); $this->assertEquals(LinksTest::$href, $links[0]->getHref());
} }
public function testSerializeDeserialize() { public function testSerializeDeserialize() {
@@ -58,7 +57,7 @@ class SaleTest extends \PHPUnit_Framework_TestCase {
$payment->create(); $payment->create();
$transactions = $payment->getTransactions(); $transactions = $payment->getTransactions();
$resources = $transactions[0]->getRelated_resources(); $resources = $transactions[0]->getRelatedResources();
$saleId = $resources[0]->getSale()->getId(); $saleId = $resources[0]->getSale()->getId();
$sale = Sale::get($saleId); $sale = Sale::get($saleId);

View File

@@ -16,7 +16,6 @@ class ShippingAddressTest extends \PHPUnit_Framework_TestCase {
public static $countryCode = "US"; public static $countryCode = "US";
public static $phone = "716-298-1822"; public static $phone = "716-298-1822";
public static $recipientName = "TestUser"; public static $recipientName = "TestUser";
public static $type = "Billing";
public static function createAddress() { public static function createAddress() {
$addr = new ShippingAddress(); $addr = new ShippingAddress();
@@ -24,11 +23,10 @@ class ShippingAddressTest extends \PHPUnit_Framework_TestCase {
$addr->setLine2(self::$line2); $addr->setLine2(self::$line2);
$addr->setCity(self::$city); $addr->setCity(self::$city);
$addr->setState(self::$state); $addr->setState(self::$state);
$addr->setPostal_code(self::$postalCode); $addr->setPostalCode(self::$postalCode);
$addr->setCountry_code(self::$countryCode); $addr->setCountryCode(self::$countryCode);
$addr->setPhone(self::$phone); $addr->setPhone(self::$phone);
$addr->setRecipient_name(self::$recipientName); $addr->setRecipientName(self::$recipientName);
$addr->setType(self::$type);
return $addr; return $addr;
} }
@@ -41,11 +39,10 @@ class ShippingAddressTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals(self::$line2, $this->address->getLine2()); $this->assertEquals(self::$line2, $this->address->getLine2());
$this->assertEquals(self::$city, $this->address->getCity()); $this->assertEquals(self::$city, $this->address->getCity());
$this->assertEquals(self::$state, $this->address->getState()); $this->assertEquals(self::$state, $this->address->getState());
$this->assertEquals(self::$postalCode, $this->address->getPostal_code()); $this->assertEquals(self::$postalCode, $this->address->getPostalCode());
$this->assertEquals(self::$countryCode, $this->address->getCountry_code()); $this->assertEquals(self::$countryCode, $this->address->getCountryCode());
$this->assertEquals(self::$phone, $this->address->getPhone()); $this->assertEquals(self::$phone, $this->address->getPhone());
$this->assertEquals(self::$recipientName, $this->address->getRecipient_name()); $this->assertEquals(self::$recipientName, $this->address->getRecipientName());
$this->assertEquals(self::$type, $this->address->getType());
} }
public function testSerializeDeserialize() { public function testSerializeDeserialize() {

View File

@@ -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);
}
}

View File

@@ -18,9 +18,9 @@ class TransactionTest extends \PHPUnit_Framework_TestCase {
$transaction = new Transaction(); $transaction = new Transaction();
$transaction->setAmount(AmountTest::createAmount()); $transaction->setAmount(AmountTest::createAmount());
$transaction->setDescription(self::$description); $transaction->setDescription(self::$description);
$transaction->setItem_list(ItemListTest::createItemList()); $transaction->setItemList(ItemListTest::createItemList());
$transaction->setPayee(PayeeTest::createPayee()); $transaction->setPayee(PayeeTest::createPayee());
$transaction->setRelated_resources( array(SubTransactionTest::createSubTransaction()) ); $transaction->setRelatedResources( array(RelatedResourcesTest::createRelatedResources()) );
return $transaction; return $transaction;
} }
@@ -31,11 +31,11 @@ class TransactionTest extends \PHPUnit_Framework_TestCase {
public function testGetterSetter() { public function testGetterSetter() {
$this->assertEquals(AmountTest::$currency, $this->transaction->getAmount()->getCurrency()); $this->assertEquals(AmountTest::$currency, $this->transaction->getAmount()->getCurrency());
$this->assertEquals(self::$description, $this->transaction->getDescription()); $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(ItemTest::$quantity, $items[0]->getQuantity());
$this->assertEquals(PayeeTest::$email, $this->transaction->getPayee()->getEmail()); $this->assertEquals(PayeeTest::$email, $this->transaction->getPayee()->getEmail());
$resources = $this->transaction->getRelated_resources(); $resources = $this->transaction->getRelatedResources();
$this->assertEquals(AuthorizationTest::$create_time, $resources[0]->getAuthorization()->getCreate_Time()); $this->assertEquals(AuthorizationTest::$create_time, $resources[0]->getAuthorization()->getCreateTime());
} }
public function testSerializeDeserialize() { public function testSerializeDeserialize() {