Updated Invoicing APIs

- Updated Model objects.
- Updated Samples.
- Updated Tests.
This commit is contained in:
Jay Patel
2016-07-13 15:16:25 -05:00
parent 9534bcb176
commit c714f77980
48 changed files with 3320 additions and 2881 deletions

View File

@@ -0,0 +1,68 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\FileAttachment;
/**
* Class FileAttachment
*
* @package PayPal\Test\Api
*/
class FileAttachmentTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object FileAttachment
* @return string
*/
public static function getJson()
{
return '{"name":"TestSample","url":"http://www.google.com"}';
}
/**
* Gets Object Instance with Json data filled in
* @return FileAttachment
*/
public static function getObject()
{
return new FileAttachment(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return FileAttachment
*/
public function testSerializationDeserialization()
{
$obj = new FileAttachment(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getUrl());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param FileAttachment $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getUrl(), "http://www.google.com");
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Url is not a fully qualified URL
*/
public function testUrlValidationForUrl()
{
$obj = new FileAttachment();
$obj->setUrl(null);
}
}

View File

@@ -17,7 +17,7 @@ class InvoiceItemTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"name":"TestSample","description":"TestSample","quantity":"12.34","unit_price":' .CurrencyTest::getJson() . ',"tax":' .TaxTest::getJson() . ',"date":"TestSample","discount":' .CostTest::getJson() . '}';
return '{"name":"TestSample","description":"TestSample","quantity":"12.34","unit_price":' .CurrencyTest::getJson() . ',"tax":' .TaxTest::getJson() . ',"date":"TestSample","discount":' .CostTest::getJson() . ',"image_url":"http://www.google.com","unit_of_measure":"TestSample"}';
}
/**
@@ -45,6 +45,8 @@ class InvoiceItemTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getTax());
$this->assertNotNull($obj->getDate());
$this->assertNotNull($obj->getDiscount());
$this->assertNotNull($obj->getImageUrl());
$this->assertNotNull($obj->getUnitOfMeasure());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -62,6 +64,18 @@ class InvoiceItemTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getTax(), TaxTest::getObject());
$this->assertEquals($obj->getDate(), "TestSample");
$this->assertEquals($obj->getDiscount(), CostTest::getObject());
$this->assertEquals($obj->getImageUrl(), "http://www.google.com");
$this->assertEquals($obj->getUnitOfMeasure(), "TestSample");
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage ImageUrl is not a fully qualified URL
*/
public function testUrlValidationForImageUrl()
{
$obj = new InvoiceItem();
$obj->setImageUrl(null);
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Api\InvoiceNumber;
/**
* Class Cost
*
* @package PayPal\Test\Api
*/
class InvoiceNumberTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Cost
* @return string
*/
public static function getJson()
{
return '{"number":"1234"}';
}
/**
* Gets Object Instance with Json data filled in
* @return InvoiceNumber
*/
public static function getObject()
{
return new InvoiceNumber(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return InvoiceNumber
*/
public function testSerializationDeserialization()
{
$obj = new InvoiceNumber(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getNumber());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param InvoiceNumber $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getNumber(), "1234");
}
}

View File

@@ -3,6 +3,7 @@
namespace PayPal\Test\Api;
use PayPal\Api\Invoice;
use PayPal\Api\InvoiceNumber;
/**
* Class Invoice
@@ -17,7 +18,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"id":"TestSample","number":"TestSample","uri":"TestSample","status":"TestSample","merchant_info":' .MerchantInfoTest::getJson() . ',"billing_info":' .BillingInfoTest::getJson() . ',"shipping_info":' .ShippingInfoTest::getJson() . ',"items":' .InvoiceItemTest::getJson() . ',"invoice_date":"TestSample","payment_term":' .PaymentTermTest::getJson() . ',"discount":' .CostTest::getJson() . ',"shipping_cost":' .ShippingCostTest::getJson() . ',"custom":' .CustomAmountTest::getJson() . ',"tax_calculated_after_discount":true,"tax_inclusive":true,"terms":"TestSample","note":"TestSample","merchant_memo":"TestSample","logo_url":"http://www.google.com","total_amount":' .CurrencyTest::getJson() . ',"payments":' .PaymentDetailTest::getJson() . ',"refunds":' .RefundDetailTest::getJson() . ',"metadata":' .MetadataTest::getJson() . ',"additional_data":"TestSample"}';
return '{"id":"TestSample","number":"TestSample","template_id":"TestSample","uri":"TestSample","status":"TestSample","merchant_info":' .MerchantInfoTest::getJson() . ',"billing_info":' .BillingInfoTest::getJson() . ',"cc_info":' .ParticipantTest::getJson() . ',"shipping_info":' .ShippingInfoTest::getJson() . ',"items":' .InvoiceItemTest::getJson() . ',"invoice_date":"TestSample","payment_term":' .PaymentTermTest::getJson() . ',"reference":"TestSample","discount":' .CostTest::getJson() . ',"shipping_cost":' .ShippingCostTest::getJson() . ',"custom":' .CustomAmountTest::getJson() . ',"allow_partial_payment":true,"minimum_amount_due":' .CurrencyTest::getJson() . ',"tax_calculated_after_discount":true,"tax_inclusive":true,"terms":"TestSample","note":"TestSample","merchant_memo":"TestSample","logo_url":"http://www.google.com","total_amount":' .CurrencyTest::getJson() . ',"payments":' .PaymentDetailTest::getJson() . ',"refunds":' .RefundDetailTest::getJson() . ',"metadata":' .MetadataTest::getJson() . ',"additional_data":"TestSample","gratuity":' .CurrencyTest::getJson() . ',"paid_amount":' .PaymentSummaryTest::getJson() . ',"refunded_amount":' .PaymentSummaryTest::getJson() . ',"attachments":' .FileAttachmentTest::getJson() . '}';
}
/**
@@ -40,17 +41,22 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj);
$this->assertNotNull($obj->getId());
$this->assertNotNull($obj->getNumber());
$this->assertNotNull($obj->getTemplateId());
$this->assertNotNull($obj->getUri());
$this->assertNotNull($obj->getStatus());
$this->assertNotNull($obj->getMerchantInfo());
$this->assertNotNull($obj->getBillingInfo());
$this->assertNotNull($obj->getCcInfo());
$this->assertNotNull($obj->getShippingInfo());
$this->assertNotNull($obj->getItems());
$this->assertNotNull($obj->getInvoiceDate());
$this->assertNotNull($obj->getPaymentTerm());
$this->assertNotNull($obj->getReference());
$this->assertNotNull($obj->getDiscount());
$this->assertNotNull($obj->getShippingCost());
$this->assertNotNull($obj->getCustom());
$this->assertNotNull($obj->getAllowPartialPayment());
$this->assertNotNull($obj->getMinimumAmountDue());
$this->assertNotNull($obj->getTaxCalculatedAfterDiscount());
$this->assertNotNull($obj->getTaxInclusive());
$this->assertNotNull($obj->getTerms());
@@ -62,6 +68,9 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getRefunds());
$this->assertNotNull($obj->getMetadata());
$this->assertNotNull($obj->getAdditionalData());
$this->assertNotNull($obj->getPaidAmount());
$this->assertNotNull($obj->getRefundedAmount());
$this->assertNotNull($obj->getAttachments());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -74,17 +83,22 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
{
$this->assertEquals($obj->getId(), "TestSample");
$this->assertEquals($obj->getNumber(), "TestSample");
$this->assertEquals($obj->getTemplateId(), "TestSample");
$this->assertEquals($obj->getUri(), "TestSample");
$this->assertEquals($obj->getStatus(), "TestSample");
$this->assertEquals($obj->getMerchantInfo(), MerchantInfoTest::getObject());
$this->assertEquals($obj->getBillingInfo(), BillingInfoTest::getObject());
$this->assertEquals($obj->getCcInfo(), ParticipantTest::getObject());
$this->assertEquals($obj->getShippingInfo(), ShippingInfoTest::getObject());
$this->assertEquals($obj->getItems(), InvoiceItemTest::getObject());
$this->assertEquals($obj->getInvoiceDate(), "TestSample");
$this->assertEquals($obj->getPaymentTerm(), PaymentTermTest::getObject());
$this->assertEquals($obj->getReference(), "TestSample");
$this->assertEquals($obj->getDiscount(), CostTest::getObject());
$this->assertEquals($obj->getShippingCost(), ShippingCostTest::getObject());
$this->assertEquals($obj->getCustom(), CustomAmountTest::getObject());
$this->assertEquals($obj->getAllowPartialPayment(), true);
$this->assertEquals($obj->getMinimumAmountDue(), CurrencyTest::getObject());
$this->assertEquals($obj->getTaxCalculatedAfterDiscount(), true);
$this->assertEquals($obj->getTaxInclusive(), true);
$this->assertEquals($obj->getTerms(), "TestSample");
@@ -96,6 +110,9 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getRefunds(), RefundDetailTest::getObject());
$this->assertEquals($obj->getMetadata(), MetadataTest::getObject());
$this->assertEquals($obj->getAdditionalData(), "TestSample");
$this->assertEquals($obj->getPaidAmount(), PaymentSummaryTest::getObject());
$this->assertEquals($obj->getRefundedAmount(), PaymentSummaryTest::getObject());
$this->assertEquals($obj->getAttachments(), FileAttachmentTest::getObject());
}
/**
@@ -107,7 +124,6 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
$obj = new Invoice();
$obj->setLogoUrl(null);
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
@@ -297,7 +313,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
$mockPayPalRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
self::getJson()
self::getJson()
));
$result = $obj->update($mockApiContext, $mockPayPalRestCall);
@@ -316,7 +332,7 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
$mockPayPalRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
true
true
));
$result = $obj->delete($mockApiContext, $mockPayPalRestCall);
@@ -335,12 +351,31 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
$mockPayPalRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
ImageTest::getJson()
ImageTest::getJson()
));
$result = $obj->qrCode("invoiceId", array(), $mockApiContext, $mockPayPalRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Invoice $obj
*/
public function testGenerateNumber($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
InvoiceNumberTest::getJson()
));
$result = $obj->generateNumber($mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
public function mockProvider()
{

View File

@@ -17,7 +17,7 @@ class MerchantInfoTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"email":"TestSample","first_name":"TestSample","last_name":"TestSample","address":' .AddressTest::getJson() . ',"business_name":"TestSample","phone":' .PhoneTest::getJson() . ',"fax":' .PhoneTest::getJson() . ',"website":"TestSample","tax_id":"TestSample","additional_info":"TestSample"}';
return '{"email":"TestSample","first_name":"TestSample","last_name":"TestSample","address":' .AddressTest::getJson() . ',"business_name":"TestSample","phone":' .PhoneTest::getJson() . ',"fax":' .PhoneTest::getJson() . ',"website":"TestSample","tax_id":"TestSample","additional_info_label":"TestSample","additional_info":"TestSample"}';
}
/**
@@ -47,6 +47,7 @@ class MerchantInfoTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getFax());
$this->assertNotNull($obj->getWebsite());
$this->assertNotNull($obj->getTaxId());
$this->assertNotNull($obj->getAdditionalInfoLabel());
$this->assertNotNull($obj->getAdditionalInfo());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
@@ -67,6 +68,7 @@ class MerchantInfoTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getFax(), PhoneTest::getObject());
$this->assertEquals($obj->getWebsite(), "TestSample");
$this->assertEquals($obj->getTaxId(), "TestSample");
$this->assertEquals($obj->getAdditionalInfoLabel(), "TestSample");
$this->assertEquals($obj->getAdditionalInfo(), "TestSample");
}

View File

@@ -0,0 +1,73 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\Participant;
/**
* Class Participant
*
* @package PayPal\Test\Api
*/
class ParticipantTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Participant
* @return string
*/
public static function getJson()
{
return '{"email":"TestSample","first_name":"TestSample","last_name":"TestSample","business_name":"TestSample","phone":' .PhoneTest::getJson() . ',"fax":' .PhoneTest::getJson() . ',"website":"TestSample","additional_info":"TestSample","address":' .AddressTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return Participant
*/
public static function getObject()
{
return new Participant(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Participant
*/
public function testSerializationDeserialization()
{
$obj = new Participant(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getEmail());
$this->assertNotNull($obj->getFirstName());
$this->assertNotNull($obj->getLastName());
$this->assertNotNull($obj->getBusinessName());
$this->assertNotNull($obj->getPhone());
$this->assertNotNull($obj->getFax());
$this->assertNotNull($obj->getWebsite());
$this->assertNotNull($obj->getAdditionalInfo());
$this->assertNotNull($obj->getAddress());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Participant $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getEmail(), "TestSample");
$this->assertEquals($obj->getFirstName(), "TestSample");
$this->assertEquals($obj->getLastName(), "TestSample");
$this->assertEquals($obj->getBusinessName(), "TestSample");
$this->assertEquals($obj->getPhone(), PhoneTest::getObject());
$this->assertEquals($obj->getFax(), PhoneTest::getObject());
$this->assertEquals($obj->getWebsite(), "TestSample");
$this->assertEquals($obj->getAdditionalInfo(), "TestSample");
$this->assertEquals($obj->getAddress(), AddressTest::getObject());
}
}

View File

@@ -17,7 +17,7 @@ class PaymentDetailTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"type":"TestSample","transaction_id":"TestSample","transaction_type":"TestSample","date":"TestSample","method":"TestSample","note":"TestSample"}';
return '{"type":"TestSample","transaction_id":"TestSample","transaction_type":"TestSample","date":"TestSample","method":"TestSample","note":"TestSample","amount":' .CurrencyTest::getJson() . '}';
}
/**
@@ -44,6 +44,7 @@ class PaymentDetailTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getDate());
$this->assertNotNull($obj->getMethod());
$this->assertNotNull($obj->getNote());
$this->assertNotNull($obj->getAmount());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -60,6 +61,7 @@ class PaymentDetailTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getDate(), "TestSample");
$this->assertEquals($obj->getMethod(), "TestSample");
$this->assertEquals($obj->getNote(), "TestSample");
$this->assertEquals($obj->getAmount(), CurrencyTest::getObject());
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\PaymentSummary;
/**
* Class PaymentSummary
*
* @package PayPal\Test\Api
*/
class PaymentSummaryTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object PaymentSummary
* @return string
*/
public static function getJson()
{
return '{"paypal":' .CurrencyTest::getJson() . ',"other":' .CurrencyTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return PaymentSummary
*/
public static function getObject()
{
return new PaymentSummary(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return PaymentSummary
*/
public function testSerializationDeserialization()
{
$obj = new PaymentSummary(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getPaypal());
$this->assertNotNull($obj->getOther());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param PaymentSummary $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getPaypal(), CurrencyTest::getObject());
$this->assertEquals($obj->getOther(), CurrencyTest::getObject());
}
}

View File

@@ -17,7 +17,7 @@ class RefundDetailTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"type":"TestSample","date":"TestSample","note":"TestSample"}';
return '{"type":"TestSample","date":"TestSample","note":"TestSample","amount":' .CurrencyTest::getJson() . '}';
}
/**
@@ -41,6 +41,7 @@ class RefundDetailTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getType());
$this->assertNotNull($obj->getDate());
$this->assertNotNull($obj->getNote());
$this->assertNotNull($obj->getAmount());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -54,6 +55,8 @@ class RefundDetailTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getType(), "TestSample");
$this->assertEquals($obj->getDate(), "TestSample");
$this->assertEquals($obj->getNote(), "TestSample");
$this->assertEquals($obj->getAmount(), CurrencyTest::getObject());
}
}

View File

@@ -17,7 +17,7 @@ class SearchTest extends \PHPUnit_Framework_TestCase
*/
public static function getJson()
{
return '{"email":"TestSample","recipient_first_name":"TestSample","recipient_last_name":"TestSample","recipient_business_name":"TestSample","number":"TestSample","status":"TestSample","lower_total_amount":' .CurrencyTest::getJson() . ',"upper_total_amount":' .CurrencyTest::getJson() . ',"start_invoice_date":"TestSample","end_invoice_date":"TestSample","start_due_date":"TestSample","end_due_date":"TestSample","start_payment_date":"TestSample","end_payment_date":"TestSample","start_creation_date":"TestSample","end_creation_date":"TestSample","page":"12.34","page_size":"12.34","total_count_required":true}';
return '{"email":"TestSample","recipient_first_name":"TestSample","recipient_last_name":"TestSample","recipient_business_name":"TestSample","number":"TestSample","status":"TestSample","lower_total_amount":' .CurrencyTest::getJson() . ',"upper_total_amount":' .CurrencyTest::getJson() . ',"start_invoice_date":"TestSample","end_invoice_date":"TestSample","start_due_date":"TestSample","end_due_date":"TestSample","start_payment_date":"TestSample","end_payment_date":"TestSample","start_creation_date":"TestSample","end_creation_date":"TestSample","page":"12.34","page_size":"12.34","total_count_required":true,"archived":true}';
}
/**
@@ -57,6 +57,7 @@ class SearchTest extends \PHPUnit_Framework_TestCase
$this->assertNotNull($obj->getPage());
$this->assertNotNull($obj->getPageSize());
$this->assertNotNull($obj->getTotalCountRequired());
$this->assertNotNull($obj->getArchived());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
@@ -86,6 +87,7 @@ class SearchTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($obj->getPage(), "12.34");
$this->assertEquals($obj->getPageSize(), "12.34");
$this->assertEquals($obj->getTotalCountRequired(), true);
$this->assertEquals($obj->getArchived(), true);
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\TemplateData;
/**
* Class TemplateData
*
* @package PayPal\Test\Api
*/
class TemplateDataTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object TemplateData
* @return string
*/
public static function getJson()
{
return '{"merchant_info":' .MerchantInfoTest::getJson() . ',"billing_info":' .BillingInfoTest::getJson() . ',"shipping_info":' .ShippingInfoTest::getJson() . ',"items":' .InvoiceItemTest::getJson() . ',"payment_term":' .PaymentTermTest::getJson() . ',"reference":"TestSample","discount":' .CostTest::getJson() . ',"shipping_cost":' .ShippingCostTest::getJson() . ',"custom":' .CustomAmountTest::getJson() . ',"allow_partial_payment":true,"minimum_amount_due":' .CurrencyTest::getJson() . ',"tax_calculated_after_discount":true,"tax_inclusive":true,"terms":"TestSample","note":"TestSample","merchant_memo":"TestSample","logo_url":"http://www.google.com","total_amount":' .CurrencyTest::getJson() . ',"attachments":' .FileAttachmentTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return TemplateData
*/
public static function getObject()
{
return new TemplateData(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return TemplateData
*/
public function testSerializationDeserialization()
{
$obj = new TemplateData(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getMerchantInfo());
$this->assertNotNull($obj->getBillingInfo());
$this->assertNotNull($obj->getShippingInfo());
$this->assertNotNull($obj->getItems());
$this->assertNotNull($obj->getPaymentTerm());
$this->assertNotNull($obj->getReference());
$this->assertNotNull($obj->getDiscount());
$this->assertNotNull($obj->getShippingCost());
$this->assertNotNull($obj->getCustom());
$this->assertNotNull($obj->getAllowPartialPayment());
$this->assertNotNull($obj->getMinimumAmountDue());
$this->assertNotNull($obj->getTaxCalculatedAfterDiscount());
$this->assertNotNull($obj->getTaxInclusive());
$this->assertNotNull($obj->getTerms());
$this->assertNotNull($obj->getNote());
$this->assertNotNull($obj->getMerchantMemo());
$this->assertNotNull($obj->getLogoUrl());
$this->assertNotNull($obj->getTotalAmount());
$this->assertNotNull($obj->getAttachments());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param TemplateData $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getMerchantInfo(), MerchantInfoTest::getObject());
$this->assertEquals($obj->getBillingInfo(), BillingInfoTest::getObject());
$this->assertEquals($obj->getShippingInfo(), ShippingInfoTest::getObject());
$this->assertEquals($obj->getItems(), InvoiceItemTest::getObject());
$this->assertEquals($obj->getPaymentTerm(), PaymentTermTest::getObject());
$this->assertEquals($obj->getReference(), "TestSample");
$this->assertEquals($obj->getDiscount(), CostTest::getObject());
$this->assertEquals($obj->getShippingCost(), ShippingCostTest::getObject());
$this->assertEquals($obj->getCustom(), CustomAmountTest::getObject());
$this->assertEquals($obj->getAllowPartialPayment(), true);
$this->assertEquals($obj->getMinimumAmountDue(), CurrencyTest::getObject());
$this->assertEquals($obj->getTaxCalculatedAfterDiscount(), true);
$this->assertEquals($obj->getTaxInclusive(), true);
$this->assertEquals($obj->getTerms(), "TestSample");
$this->assertEquals($obj->getNote(), "TestSample");
$this->assertEquals($obj->getMerchantMemo(), "TestSample");
$this->assertEquals($obj->getLogoUrl(), "http://www.google.com");
$this->assertEquals($obj->getTotalAmount(), CurrencyTest::getObject());
$this->assertEquals($obj->getAttachments(), FileAttachmentTest::getObject());
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage LogoUrl is not a fully qualified URL
*/
public function testUrlValidationForLogoUrl()
{
$obj = new TemplateData();
$obj->setLogoUrl(null);
}
}

View File

@@ -0,0 +1,57 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\TemplateSettingsMetadata;
/**
* Class TemplateSettingsMetadata
*
* @package PayPal\Test\Api
*/
class TemplateSettingsMetadataTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object TemplateSettingsMetadata
* @return string
*/
public static function getJson()
{
return '{"hidden":true}';
}
/**
* Gets Object Instance with Json data filled in
* @return TemplateSettingsMetadata
*/
public static function getObject()
{
return new TemplateSettingsMetadata(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return TemplateSettingsMetadata
*/
public function testSerializationDeserialization()
{
$obj = new TemplateSettingsMetadata(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getHidden());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param TemplateSettingsMetadata $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getHidden(), true);
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\TemplateSettings;
/**
* Class TemplateSettings
*
* @package PayPal\Test\Api
*/
class TemplateSettingsTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object TemplateSettings
* @return string
*/
public static function getJson()
{
return '{"field_name":"TestSample","display_preference":' .TemplateSettingsMetadataTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return TemplateSettings
*/
public static function getObject()
{
return new TemplateSettings(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return TemplateSettings
*/
public function testSerializationDeserialization()
{
$obj = new TemplateSettings(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getFieldName());
$this->assertNotNull($obj->getDisplayPreference());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param TemplateSettings $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getFieldName(), "TestSample");
$this->assertEquals($obj->getDisplayPreference(), TemplateSettingsMetadataTest::getObject());
}
}

View File

@@ -0,0 +1,69 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalModel;
use PayPal\Api\Template;
/**
* Class Template
*
* @package PayPal\Test\Api
*/
class TemplateTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Template
* @return string
*/
public static function getJson()
{
return '{"template_id":"TestSample","name":"TestSample","default":true,"template_data":' .TemplateDataTest::getJson() . ',"settings":' .TemplateSettingsTest::getJson() . ',"unit_of_measure":"TestSample","custom":true}';
}
/**
* Gets Object Instance with Json data filled in
* @return Template
*/
public static function getObject()
{
return new Template(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Template
*/
public function testSerializationDeserialization()
{
$obj = new Template(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getTemplateId());
$this->assertNotNull($obj->getName());
$this->assertNotNull($obj->getDefault());
$this->assertNotNull($obj->getTemplateData());
$this->assertNotNull($obj->getSettings());
$this->assertNotNull($obj->getUnitOfMeasure());
$this->assertNotNull($obj->getCustom());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Template $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getTemplateId(), "TestSample");
$this->assertEquals($obj->getName(), "TestSample");
$this->assertEquals($obj->getDefault(), true);
$this->assertEquals($obj->getTemplateData(), TemplateDataTest::getObject());
$this->assertEquals($obj->getSettings(), TemplateSettingsTest::getObject());
$this->assertEquals($obj->getUnitOfMeasure(), "TestSample");
$this->assertEquals($obj->getCustom(), true);
}
}

View File

@@ -0,0 +1,118 @@
<?php
namespace PayPal\Test\Api;
use PayPal\Common\PayPalResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\Template;
use PayPal\Rest\ApiContext;
use PayPal\Api\Templates;
/**
* Class Templates
*
* @package PayPal\Test\Api
*/
class TemplatesTest extends \PHPUnit_Framework_TestCase
{
/**
* Gets Json String of Object Templates
* @return string
*/
public static function getJson()
{
return '{"addresses":' .AddressTest::getJson() . ',"emails":"TestSample","phones":' .PhoneTest::getJson() . ',"templates":' .TemplateTest::getJson() . ',"links":' .LinksTest::getJson() . '}';
}
/**
* Gets Object Instance with Json data filled in
* @return Templates
*/
public static function getObject()
{
return new Templates(self::getJson());
}
/**
* Tests for Serialization and Deserialization Issues
* @return Templates
*/
public function testSerializationDeserialization()
{
$obj = new Templates(self::getJson());
$this->assertNotNull($obj);
$this->assertNotNull($obj->getAddresses());
$this->assertNotNull($obj->getEmails());
$this->assertNotNull($obj->getPhones());
$this->assertNotNull($obj->getTemplates());
$this->assertNotNull($obj->getLinks());
$this->assertEquals(self::getJson(), $obj->toJson());
return $obj;
}
/**
* @depends testSerializationDeserialization
* @param Templates $obj
*/
public function testGetters($obj)
{
$this->assertEquals($obj->getAddresses(), AddressTest::getObject());
$this->assertEquals($obj->getEmails(), "TestSample");
$this->assertEquals($obj->getPhones(), PhoneTest::getObject());
$this->assertEquals($obj->getTemplates(), TemplateTest::getObject());
$this->assertEquals($obj->getLinks(), LinksTest::getObject());
}
/**
* @dataProvider mockProvider
* @param Templates $obj
*/
public function testGet($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
TemplateTest::getJson()
));
$result = $obj->get("templateId", $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
/**
* @dataProvider mockProvider
* @param Templates $obj
*/
public function testGetAll($obj, $mockApiContext)
{
$mockPPRestCall = $this->getMockBuilder('\PayPal\Transport\PayPalRestCall')
->disableOriginalConstructor()
->getMock();
$mockPPRestCall->expects($this->any())
->method('execute')
->will($this->returnValue(
TemplatesTest::getJson()
));
$params = array();
$result = $obj->getAll($params, $mockApiContext, $mockPPRestCall);
$this->assertNotNull($result);
}
public function mockProvider()
{
$obj = self::getObject();
$mockApiContext = $this->getMockBuilder('ApiContext')
->disableOriginalConstructor()
->getMock();
return array(
array($obj, $mockApiContext),
array($obj, null)
);
}
}