From 24e0609e5b10c358daeb331f93486703eb7422dd Mon Sep 17 00:00:00 2001 From: japatel Date: Thu, 20 Nov 2014 17:00:19 -0600 Subject: [PATCH] Fixing Invoice Phone Attribute - Also updated the Update Invoice Sample --- lib/PayPal/Api/Address.php | 200 +----------------- lib/PayPal/Api/BaseAddress.php | 211 +++++++++++++++++++ lib/PayPal/Api/BillingInfo.php | 6 +- lib/PayPal/Api/InvoiceAddress.php | 41 ++++ lib/PayPal/Api/MerchantInfo.php | 6 +- lib/PayPal/Api/Phone.php | 1 + lib/PayPal/Api/ShippingInfo.php | 6 +- lib/PayPal/Common/PPModel.php | 6 +- sample/doc/assets/behavior.js | 8 + sample/doc/invoice/UpdateInvoice.html | 9 +- sample/index.php | 102 ++++----- sample/invoice/UpdateInvoice.php | 17 +- sample/invoice/images/sample.png | Bin 1679 -> 1681 bytes tests/PayPal/Test/Api/BillingInfoTest.php | 4 +- tests/PayPal/Test/Api/InvoiceAddressTest.php | 108 ++++++++++ 15 files changed, 460 insertions(+), 265 deletions(-) create mode 100644 lib/PayPal/Api/BaseAddress.php create mode 100644 lib/PayPal/Api/InvoiceAddress.php create mode 100644 tests/PayPal/Test/Api/InvoiceAddressTest.php diff --git a/lib/PayPal/Api/Address.php b/lib/PayPal/Api/Address.php index 7b93d48..693fa2d 100644 --- a/lib/PayPal/Api/Address.php +++ b/lib/PayPal/Api/Address.php @@ -11,208 +11,14 @@ use PayPal\Common\PPModel; * * @package PayPal\Api * - * @property string line1 - * @property string line2 - * @property string city - * @property string country_code - * @property string postal_code - * @property string state * @property string phone */ -class Address extends PPModel +class Address extends BaseAddress { - /** - * Line 1 of the Address (eg. number, street, etc). - * - * @param string $line1 - * - * @return $this - */ - public function setLine1($line1) - { - $this->line1 = $line1; - return $this; - } - - /** - * Line 1 of the Address (eg. number, street, etc). - * - * @return string - */ - public function getLine1() - { - return $this->line1; - } - - /** - * Optional line 2 of the Address (eg. suite, apt #, etc.). - * - * @param string $line2 - * - * @return $this - */ - public function setLine2($line2) - { - $this->line2 = $line2; - return $this; - } - - /** - * Optional line 2 of the Address (eg. suite, apt #, etc.). - * - * @return string - */ - public function getLine2() - { - return $this->line2; - } - - /** - * City name. - * - * @param string $city - * - * @return $this - */ - public function setCity($city) - { - $this->city = $city; - return $this; - } - - /** - * City name. - * - * @return string - */ - public function getCity() - { - return $this->city; - } - - /** - * 2 letter country code. - * - * @param string $country_code - * - * @return $this - */ - public function setCountryCode($country_code) - { - $this->country_code = $country_code; - return $this; - } - - /** - * 2 letter country code. - * - * @return string - */ - public function getCountryCode() - { - return $this->country_code; - } - - /** - * 2 letter country code. - * - * @deprecated Instead use setCountryCode - * - * @param string $country_code - * @return $this - */ - public function setCountry_code($country_code) - { - $this->country_code = $country_code; - return $this; - } - - /** - * 2 letter country code. - * @deprecated Instead use getCountryCode - * - * @return string - */ - public function getCountry_code() - { - return $this->country_code; - } - - /** - * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. - * - * @param string $postal_code - * - * @return $this - */ - public function setPostalCode($postal_code) - { - $this->postal_code = $postal_code; - return $this; - } - - /** - * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. - * - * @return string - */ - public function getPostalCode() - { - return $this->postal_code; - } - - /** - * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. - * - * @deprecated Instead use setPostalCode - * - * @param string $postal_code - * @return $this - */ - public function setPostal_code($postal_code) - { - $this->postal_code = $postal_code; - return $this; - } - - /** - * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. - * @deprecated Instead use getPostalCode - * - * @return string - */ - public function getPostal_code() - { - return $this->postal_code; - } - - /** - * 2 letter code for US states, and the equivalent for other countries. - * - * @param string $state - * - * @return $this - */ - public function setState($state) - { - $this->state = $state; - return $this; - } - - /** - * 2 letter code for US states, and the equivalent for other countries. - * - * @return string - */ - public function getState() - { - return $this->state; - } - /** * Phone number in E.123 format. * - * @param \PayPal\Api\Phone $phone + * @param string $phone * * @return $this */ @@ -225,7 +31,7 @@ class Address extends PPModel /** * Phone number in E.123 format. * - * @return \PayPal\Api\Phone + * @return string */ public function getPhone() { diff --git a/lib/PayPal/Api/BaseAddress.php b/lib/PayPal/Api/BaseAddress.php new file mode 100644 index 0000000..d5ab7cf --- /dev/null +++ b/lib/PayPal/Api/BaseAddress.php @@ -0,0 +1,211 @@ +line1 = $line1; + return $this; + } + + /** + * Line 1 of the Address (eg. number, street, etc). + * + * @return string + */ + public function getLine1() + { + return $this->line1; + } + + /** + * Optional line 2 of the Address (eg. suite, apt #, etc.). + * + * @param string $line2 + * + * @return $this + */ + public function setLine2($line2) + { + $this->line2 = $line2; + return $this; + } + + /** + * Optional line 2 of the Address (eg. suite, apt #, etc.). + * + * @return string + */ + public function getLine2() + { + return $this->line2; + } + + /** + * City name. + * + * @param string $city + * + * @return $this + */ + public function setCity($city) + { + $this->city = $city; + return $this; + } + + /** + * City name. + * + * @return string + */ + public function getCity() + { + return $this->city; + } + + /** + * 2 letter country code. + * + * @param string $country_code + * + * @return $this + */ + public function setCountryCode($country_code) + { + $this->country_code = $country_code; + return $this; + } + + /** + * 2 letter country code. + * + * @return string + */ + public function getCountryCode() + { + return $this->country_code; + } + + /** + * 2 letter country code. + * + * @deprecated Instead use setCountryCode + * + * @param string $country_code + * @return $this + */ + public function setCountry_code($country_code) + { + $this->country_code = $country_code; + return $this; + } + + /** + * 2 letter country code. + * @deprecated Instead use getCountryCode + * + * @return string + */ + public function getCountry_code() + { + return $this->country_code; + } + + /** + * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. + * + * @param string $postal_code + * + * @return $this + */ + public function setPostalCode($postal_code) + { + $this->postal_code = $postal_code; + return $this; + } + + /** + * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. + * + * @return string + */ + public function getPostalCode() + { + return $this->postal_code; + } + + /** + * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. + * + * @deprecated Instead use setPostalCode + * + * @param string $postal_code + * @return $this + */ + public function setPostal_code($postal_code) + { + $this->postal_code = $postal_code; + return $this; + } + + /** + * Zip code or equivalent is usually required for countries that have them. For list of countries that do not have postal codes please refer to http://en.wikipedia.org/wiki/Postal_code. + * @deprecated Instead use getPostalCode + * + * @return string + */ + public function getPostal_code() + { + return $this->postal_code; + } + + /** + * 2 letter code for US states, and the equivalent for other countries. + * + * @param string $state + * + * @return $this + */ + public function setState($state) + { + $this->state = $state; + return $this; + } + + /** + * 2 letter code for US states, and the equivalent for other countries. + * + * @return string + */ + public function getState() + { + return $this->state; + } + +} diff --git a/lib/PayPal/Api/BillingInfo.php b/lib/PayPal/Api/BillingInfo.php index 435a7d9..fdc1edf 100644 --- a/lib/PayPal/Api/BillingInfo.php +++ b/lib/PayPal/Api/BillingInfo.php @@ -15,7 +15,7 @@ use PayPal\Common\PPModel; * @property string first_name * @property string last_name * @property string business_name - * @property \PayPal\Api\Address address + * @property \PayPal\Api\InvoiceAddress address * @property string language * @property string additional_info * @property string notification_channel @@ -193,7 +193,7 @@ class BillingInfo extends PPModel /** * Address of the invoice recipient. * - * @param \PayPal\Api\Address $address + * @param \PayPal\Api\InvoiceAddress $address * * @return $this */ @@ -206,7 +206,7 @@ class BillingInfo extends PPModel /** * Address of the invoice recipient. * - * @return \PayPal\Api\Address + * @return \PayPal\Api\InvoiceAddress */ public function getAddress() { diff --git a/lib/PayPal/Api/InvoiceAddress.php b/lib/PayPal/Api/InvoiceAddress.php new file mode 100644 index 0000000..4f7f5b4 --- /dev/null +++ b/lib/PayPal/Api/InvoiceAddress.php @@ -0,0 +1,41 @@ +phone = $phone; + return $this; + } + + /** + * Phone number in E.123 format. + * + * @return \PayPal\Api\Phone + */ + public function getPhone() + { + return $this->phone; + } + +} diff --git a/lib/PayPal/Api/MerchantInfo.php b/lib/PayPal/Api/MerchantInfo.php index a5a38eb..2389985 100644 --- a/lib/PayPal/Api/MerchantInfo.php +++ b/lib/PayPal/Api/MerchantInfo.php @@ -14,7 +14,7 @@ use PayPal\Common\PPModel; * @property string email * @property string first_name * @property string last_name - * @property \PayPal\Api\Address address + * @property \PayPal\Api\InvoiceAddress address * @property string business_name * @property \PayPal\Api\Phone phone * @property \PayPal\Api\Phone fax @@ -146,7 +146,7 @@ class MerchantInfo extends PPModel /** * Address of the merchant. * - * @param \PayPal\Api\Address $address + * @param \PayPal\Api\InvoiceAddress $address * * @return $this */ @@ -159,7 +159,7 @@ class MerchantInfo extends PPModel /** * Address of the merchant. * - * @return \PayPal\Api\Address + * @return \PayPal\Api\InvoiceAddress */ public function getAddress() { diff --git a/lib/PayPal/Api/Phone.php b/lib/PayPal/Api/Phone.php index dd8a4b7..1c55e98 100644 --- a/lib/PayPal/Api/Phone.php +++ b/lib/PayPal/Api/Phone.php @@ -13,6 +13,7 @@ use PayPal\Common\PPModel; * * @property string country_code * @property string national_number + * @property string extension */ class Phone extends PPModel { diff --git a/lib/PayPal/Api/ShippingInfo.php b/lib/PayPal/Api/ShippingInfo.php index 1f9ab5b..423f8ff 100644 --- a/lib/PayPal/Api/ShippingInfo.php +++ b/lib/PayPal/Api/ShippingInfo.php @@ -15,7 +15,7 @@ use PayPal\Common\PPModel; * @property string last_name * @property string business_name * @property \PayPal\Api\Phone phone - * @property \PayPal\Api\Address address + * @property \PayPal\Api\InvoiceAddress address */ class ShippingInfo extends PPModel { @@ -188,7 +188,7 @@ class ShippingInfo extends PPModel /** * Address of the invoice recipient. * - * @param \PayPal\Api\Address $address + * @param \PayPal\Api\InvoiceAddress $address * * @return $this */ @@ -201,7 +201,7 @@ class ShippingInfo extends PPModel /** * Address of the invoice recipient. * - * @return \PayPal\Api\Address + * @return \PayPal\Api\InvoiceAddress */ public function getAddress() { diff --git a/lib/PayPal/Common/PPModel.php b/lib/PayPal/Common/PPModel.php index fa38945..bdcf662 100644 --- a/lib/PayPal/Common/PPModel.php +++ b/lib/PayPal/Common/PPModel.php @@ -87,7 +87,11 @@ class PPModel public function __set($key, $value) { ModelAccessorValidator::validate($this, $this->convertToCamelCase($key)); - $this->_propMap[$key] = $value; + if ($value == null) { + $this->__unset($key); + } else { + $this->_propMap[$key] = $value; + } } /** diff --git a/sample/doc/assets/behavior.js b/sample/doc/assets/behavior.js index 72151e9..a79fd10 100644 --- a/sample/doc/assets/behavior.js +++ b/sample/doc/assets/behavior.js @@ -1020,6 +1020,14 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3 "slug": "update-invoice" }, "depth": 3 + }, { + "type": "heading", + "data": { + "level": 3, + "title": "NOTE: These are the work-around added to the", + "slug": "note-these-are-the-work-around-added-to-the" + }, + "depth": 3 }, { "type": "heading", "data": { diff --git a/sample/doc/invoice/UpdateInvoice.html b/sample/doc/invoice/UpdateInvoice.html index 888a2dd..ff27d5c 100644 --- a/sample/doc/invoice/UpdateInvoice.html +++ b/sample/doc/invoice/UpdateInvoice.html @@ -2,8 +2,13 @@

This sample code demonstrate how you can update an invoice.

/** @var Invoice $invoice */ $invoice = require 'CreateInvoice.php'; -use PayPal\Api\Invoice;

Update Invoice

-

Lets update some information

$invoice->setInvoiceDate("2014-11-16 PST");

For Sample Purposes Only.

$request = clone $invoice; +use PayPal\Api\Invoice;

For Sample Purposes Only.

$request = clone $invoice;

Update Invoice

+

Lets update some information

$invoice->setInvoiceDate("2014-12-16 PST");

NOTE: These are the work-around added to the

+

sample, to get past the bug in PayPal APIs. +There is already an internal ticket #PPTIPS-1932 created for it.

$invoice->setDiscount(null); +$billingInfo = $invoice->getBillingInfo()[0]; +$billingInfo->setAddress(null); +$invoice->getPaymentTerm()->setDueDate(null); try {

Update Invoice

Update an invoice by calling the invoice->update() method diff --git a/sample/index.php b/sample/index.php index 5bbc2de..c1bcb6d 100644 --- a/sample/index.php +++ b/sample/index.php @@ -44,6 +44,10 @@ if (PHP_SAPI == 'cli') { -webkit-font-smoothing: antialiased; } + li.list-group-item:hover { + background-color: #EEE; + } + @media (max-width: 992px) { .jumbotron { background: white; @@ -201,7 +205,7 @@ if (PHP_SAPI == 'cli') {

Direct credit card payments
- Execute Try It Source @@ -213,7 +217,7 @@ if (PHP_SAPI == 'cli') {
PayPal account payments
@@ -252,7 +256,7 @@ if (PHP_SAPI == 'cli') {
Get payment details
- Execute Try It Source @@ -263,7 +267,7 @@ if (PHP_SAPI == 'cli') {
Get payment history
- Execute Try It Source @@ -285,7 +289,7 @@ if (PHP_SAPI == 'cli') {
Authorize Payment
- Execute + Try It Source
Get details of an authorized payment
- Execute Source
Get details of a captured payment
- Execute Try It Source @@ -333,7 +337,7 @@ if (PHP_SAPI == 'cli') {
Void an authorized payment
- Execute + Try It Source
Reauthorize a payment
- Execute Try It Source @@ -356,7 +360,7 @@ if (PHP_SAPI == 'cli') {
Refund captured payment
- Execute Try It Source @@ -378,7 +382,7 @@ if (PHP_SAPI == 'cli') {
Get Sale details
- Execute Try It Source @@ -389,7 +393,7 @@ if (PHP_SAPI == 'cli') {
Refund a Sale
- Execute Try It Source @@ -411,7 +415,7 @@ if (PHP_SAPI == 'cli') {
Create Billing Plan
- Execute Try It Source @@ -422,7 +426,7 @@ if (PHP_SAPI == 'cli') {
Get Billing Plan
- Execute Try It Source @@ -433,7 +437,7 @@ if (PHP_SAPI == 'cli') {
Update/Activate Plan
- Execute Try It Source @@ -446,7 +450,7 @@ if (PHP_SAPI == 'cli') {
- Execute + Try It Source @@ -457,7 +461,7 @@ if (PHP_SAPI == 'cli') {
List Billing Plans
- Execute Try It Source @@ -469,7 +473,7 @@ if (PHP_SAPI == 'cli') {
Create Billing Agreement With Credit Card
Execute Try It Source @@ -483,7 +487,7 @@ if (PHP_SAPI == 'cli') {
- Execute + Try It Source @@ -494,7 +498,7 @@ if (PHP_SAPI == 'cli') {
Get Billing Agreement
- Execute + Try It Source
Save a credit card
- Execute Try It Source @@ -566,7 +570,7 @@ if (PHP_SAPI == 'cli') {
Retrieve saved credit card
- Execute Try It Source @@ -577,7 +581,7 @@ if (PHP_SAPI == 'cli') {
Delete saved credit card
- Execute Try It Source @@ -600,7 +604,7 @@ if (PHP_SAPI == 'cli') {
Create a web experience profile
Execute Try It Source @@ -665,7 +669,7 @@ if (PHP_SAPI == 'cli') {
Delete a web experience profile
- Execute + Try It Source
Create an Invoice
- Execute Try It Source @@ -699,7 +703,7 @@ if (PHP_SAPI == 'cli') {
Send an Invoice
- Execute Try It Source @@ -710,7 +714,7 @@ if (PHP_SAPI == 'cli') {
Update an Invoice
- Execute Try It Source @@ -721,7 +725,7 @@ if (PHP_SAPI == 'cli') {
Retrieve an Invoice
- Execute Try It Source @@ -732,7 +736,7 @@ if (PHP_SAPI == 'cli') {
Get Invoices of a Merchant
- Execute Try It Source @@ -743,7 +747,7 @@ if (PHP_SAPI == 'cli') {
Search for Invoices
- Execute Try It Source @@ -754,7 +758,7 @@ if (PHP_SAPI == 'cli') {
Send an Invoice Reminder
- Execute Try It Source @@ -765,7 +769,7 @@ if (PHP_SAPI == 'cli') {
Cancel an Invoice
- Execute Try It Source @@ -776,7 +780,7 @@ if (PHP_SAPI == 'cli') {
Delete an Invoice
- Execute Try It Source @@ -787,7 +791,7 @@ if (PHP_SAPI == 'cli') {
Retrieve a QR Code
- Execute Try It Source @@ -798,7 +802,7 @@ if (PHP_SAPI == 'cli') {
Record a Payment
- Execute Try It Source @@ -809,7 +813,7 @@ if (PHP_SAPI == 'cli') {
Record a Refund
- Execute Try It Source @@ -831,7 +835,7 @@ if (PHP_SAPI == 'cli') {
Obtain User's Consent
- Execute Try It Source @@ -851,7 +855,7 @@ if (PHP_SAPI == 'cli') {
Get User Info
- Execute Try It Source @@ -864,7 +868,7 @@ if (PHP_SAPI == 'cli') {
- Execute + Try It Source diff --git a/sample/invoice/UpdateInvoice.php b/sample/invoice/UpdateInvoice.php index 2076b07..efbb1e1 100644 --- a/sample/invoice/UpdateInvoice.php +++ b/sample/invoice/UpdateInvoice.php @@ -8,14 +8,21 @@ $invoice = require 'CreateInvoice.php'; use PayPal\Api\Invoice; -// ### Update Invoice -// Lets update some information -$invoice->setInvoiceDate("2014-11-16 PST"); - - // For Sample Purposes Only. $request = clone $invoice; +// ### Update Invoice +// Lets update some information +$invoice->setInvoiceDate("2014-12-16 PST"); + +// ### NOTE: These are the work-around added to the +// sample, to get past the bug in PayPal APIs. +// There is already an internal ticket #PPTIPS-1932 created for it. +$invoice->setDiscount(null); +$billingInfo = $invoice->getBillingInfo()[0]; +$billingInfo->setAddress(null); +$invoice->getPaymentTerm()->setDueDate(null); + try { // ### Update Invoice // Update an invoice by calling the invoice->update() method diff --git a/sample/invoice/images/sample.png b/sample/invoice/images/sample.png index e1c22f8d37154b08dac60ff3e43b9a5d17712f6b..2192f3ed5fde35a4ee46294ef7a0f5a2b9ecf449 100644 GIT binary patch literal 1681 zcmeAS@N?(olHy`uVBq!ia0y~yVAKI&4kn<;H+e}V1_rhWPZ!6Kid%2*I8M54Ai#3) z@Big*W|jY(KreyV^c^W#;Rgu{-I{S;5aM%NG7R zbL2;29?(Gx&qFZS8W0D>Sh4f*zirIlcV_EFeknbDOt%3V296Lj7b>)Tm@V+GPyUvh z?8)m}{r}DlXZOGiCXh)t4s6Qx+-v1x`E`9>$^+Istd6o4cmJeOpZ8Umz@^d-L^8;>oU*CQE>^srA^9?N6!s^g_ml=CfPbU8g4!`jq7?0~LC3fHE!*1YD z=_~)OKIuI(Kc=-?Ss1I+6wmPMmbuG%O8h< zZHuT6V*^wGAn?|R>R<#}RN=44TOVDE3G z{QucUilyCeU*4JVhXKVLcnG=YCH>F!)mtgeuDg8Q^F<$-(PJKB{;|9ZdhbQxo4X;cB2mcQSz1xRd<)o*SUXpd9n*5Hitd*=9t{v z`$X9%Xy$FEN&9Vo`e0L~*z!TOCAZt|WYN2Sf2K^mJe)rL#&+}8a2ZlMRK9M;HG?6G}zSNZ+j z`&aq5*1uuF?j!*<{>$a;(z)Gr<(I!OnPU&BZMIibdUo#LZ2js6u2lFivSs&!$xkLF z_dF4+eEhx%$*~9z9I`o-lFMJ3$FO0y=A0_4lcsFg9Yt{=j-@L2yLtbGvdD{_LG6ct PRSkoutDnm{r-UW|%56S` literal 1679 zcmeAS@N?(olHy`uVBq!ia0y~yVAKI&4kn<;H+e}V1_rh;PZ!6Kid%2*I8K^lAm9>s z|No_LyfS?oR~f0^i!V1Zd9g9T@bl~KOEUJyFmXC@I(Z6s33xRHGzAE?2(?U7n4&O+ zWg*K#6%JJnRYwg+4HA`nxZf}JHa&gE&)b{B|6MVk|I6q0tp))n4#gI9;?QPq#p*Tl z@6NOQF#G=HZ3}K+W5ZAb)>n4OVymuQ`Ioa756Lu3%g-v#X2xco6G!~63pb-Hl$XB= zZAG^Xs$p};vuSsGyT4vdcH~f$fGL96+r;?L?vT!p;OBdGT5JM(VZ-i1S?o4F{GVeu zUyJ){y4o>*uybnJoH#%j>`fTsZ0`4bzNk&o-&MQ!<=x!D0<}*A8W;5psCvj^R7U!AeLZT9}Z z8{3(%2B!S~{flp=nr|1`)NS`WXe%QpR#gIdd7yG z2aCFgrQ6kaYtENd$+2tL)GUuxjbe_&4Ks!tdlDlhmalvD%(?j89Bf7@wroh8nELU~ z4iU5XPxE%4a}&Yp#kyRViLtY0_fOiE=o~#eoCkYy$ak#BlD67?WV8PI{CS`6q(8%z zl+ALS(~nE!>Wh8Pzw^C+t^yW60v$H_&K3PY?X06_M0d>YU;E}eR#hAi|1GQeU-nJi`+H}clllcHiv@$p&F7jk)i z$(PMm7RDB&9EyLW4(;4{@J{}DK95cN_m=fAVv9w^me2>!>yAGA_Un#h9xz>p%V7_& z<%v1dV#{XVpHr)GhPU+DIqc3StI#G?^#97PXINVyHEF`dqt}5I4TGnvpUXO@geCyL CGBBk8 diff --git a/tests/PayPal/Test/Api/BillingInfoTest.php b/tests/PayPal/Test/Api/BillingInfoTest.php index 55a454d..2e02be2 100644 --- a/tests/PayPal/Test/Api/BillingInfoTest.php +++ b/tests/PayPal/Test/Api/BillingInfoTest.php @@ -18,7 +18,7 @@ class BillingInfoTest extends \PHPUnit_Framework_TestCase */ public static function getJson() { - return '{"email":"TestSample","first_name":"TestSample","last_name":"TestSample","business_name":"TestSample","address":' .AddressTest::getJson() . ',"language":"TestSample","additional_info":"TestSample","notification_channel":"TestSample","phone":' .PhoneTest::getJson() . '}'; + return '{"email":"TestSample","first_name":"TestSample","last_name":"TestSample","business_name":"TestSample","address":' .InvoiceAddressTest::getJson() . ',"language":"TestSample","additional_info":"TestSample","notification_channel":"TestSample","phone":' .PhoneTest::getJson() . '}'; } /** @@ -62,7 +62,7 @@ class BillingInfoTest extends \PHPUnit_Framework_TestCase $this->assertEquals($obj->getFirstName(), "TestSample"); $this->assertEquals($obj->getLastName(), "TestSample"); $this->assertEquals($obj->getBusinessName(), "TestSample"); - $this->assertEquals($obj->getAddress(), AddressTest::getObject()); + $this->assertEquals($obj->getAddress(), InvoiceAddressTest::getObject()); $this->assertEquals($obj->getLanguage(), "TestSample"); $this->assertEquals($obj->getAdditionalInfo(), "TestSample"); $this->assertEquals($obj->getNotificationChannel(), "TestSample"); diff --git a/tests/PayPal/Test/Api/InvoiceAddressTest.php b/tests/PayPal/Test/Api/InvoiceAddressTest.php new file mode 100644 index 0000000..109e08f --- /dev/null +++ b/tests/PayPal/Test/Api/InvoiceAddressTest.php @@ -0,0 +1,108 @@ +assertNotNull($obj); + $this->assertNotNull($obj->getLine1()); + $this->assertNotNull($obj->getLine2()); + $this->assertNotNull($obj->getCity()); + $this->assertNotNull($obj->getCountryCode()); + $this->assertNotNull($obj->getPostalCode()); + $this->assertNotNull($obj->getState()); + $this->assertNotNull($obj->getPhone()); + $this->assertEquals(self::getJson(), $obj->toJson()); + return $obj; + } + + /** + * @depends testSerializationDeserialization + * @param InvoiceAddress $obj + */ + public function testGetters($obj) + { + $this->assertEquals($obj->getLine1(), "TestSample"); + $this->assertEquals($obj->getLine2(), "TestSample"); + $this->assertEquals($obj->getCity(), "TestSample"); + $this->assertEquals($obj->getCountryCode(), "TestSample"); + $this->assertEquals($obj->getPostalCode(), "TestSample"); + $this->assertEquals($obj->getState(), "TestSample"); + $this->assertEquals($obj->getPhone(), PhoneTest::getObject()); + } + + /** + * @depends testSerializationDeserialization + * @param InvoiceAddress $obj + */ + public function testDeprecatedGetters($obj) + { + $this->assertEquals($obj->getCountry_code(), "TestSample"); + $this->assertEquals($obj->getPostal_code(), "TestSample"); + } + + /** + * @depends testSerializationDeserialization + * @param InvoiceAddress $obj + */ + public function testDeprecatedSetterNormalGetter($obj) + { + + // Check for Country_code + $obj->setCountryCode(null); + $this->assertNull($obj->getCountry_code()); + $this->assertNull($obj->getCountryCode()); + $this->assertSame($obj->getCountryCode(), $obj->getCountry_code()); + $obj->setCountry_code("TestSample"); + $this->assertEquals($obj->getCountry_code(), "TestSample"); + + // Check for Postal_code + $obj->setPostalCode(null); + $this->assertNull($obj->getPostal_code()); + $this->assertNull($obj->getPostalCode()); + $this->assertSame($obj->getPostalCode(), $obj->getPostal_code()); + $obj->setPostal_code("TestSample"); + $this->assertEquals($obj->getPostal_code(), "TestSample"); + + //Test All Deprecated Getters and Normal Getters + $this->testDeprecatedGetters($obj); + $this->testGetters($obj); + } + + + +}