From: jitendrapurohit Date: Mon, 13 Jun 2016 13:07:42 +0000 (+0530) Subject: CRM-17815 - Unit Test to check due date in invoices X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5134310e887171cf657f2c0825b778c0edaa32a0;p=civicrm-core.git CRM-17815 - Unit Test to check due date in invoices --- diff --git a/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php new file mode 100644 index 0000000000..8154c06c7c --- /dev/null +++ b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php @@ -0,0 +1,92 @@ +quickCleanUpFinancialEntities(); + CRM_Utils_Hook::singleton()->reset(); + } + + /** + * CRM-17815 - Test due date and payment advice block in generated + * invoice pdf for pending and completed contributions + */ + public function testInvoiceForDueDate() { + $contactIds = array(); + $params = array( + 'output' => 'pdf_invoice', + 'forPage' => 1, + ); + + $form = new CRM_Contribute_Form_Task_Invoice(); + + $this->_individualId = $this->individualCreate(); + $contributionParams = array( + 'contact_id' => $this->_individualId, + 'total_amount' => 100, + 'financial_type_id' => 'Donation', + ); + $result = $this->callAPISuccess('Contribution', 'create', $contributionParams); + + $contributionParams['contribution_status_id'] = 2; + $contributionParams['is_pay_later'] = 1; + $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams); + + $contributionIDs = array( + array($result['id']), + array($contribution['id']), + ); + + $contactIds[] = $this->_individualId; + foreach ($contributionIDs as $contributionID) { + $invoiceHTML[current($contributionID)] = CRM_Contribute_Form_Task_Invoice::printPDF($contributionID, $params, $contactIds, $form); + } + + $this->assertNotContains('Due Date', $invoiceHTML[$result['id']]); + $this->assertNotContains('PAYMENT ADVICE', $invoiceHTML[$result['id']]); + + $this->assertContains('Due Date', $invoiceHTML[$contribution['id']]); + $this->assertContains('PAYMENT ADVICE', $invoiceHTML[$contribution['id']]); + + } + +}