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

@@ -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()
{