From: Eileen McNaughton Date: Sat, 25 Apr 2015 21:30:13 +0000 (-0600) Subject: CRM-16357 - Add for backoffice contribution form through phpunit X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a084385fc4d3a267e7ca77d2ae8256cc02b6e626;p=civicrm-core.git CRM-16357 - Add for backoffice contribution form through phpunit --- diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php new file mode 100644 index 0000000000..a4c68a991a --- /dev/null +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -0,0 +1,181 @@ +_apiversion = 3; + $this->_individualId = $this->individualCreate(); + $paymentProcessor = $this->processorCreate(); + $this->_params = array( + 'contact_id' => $this->_individualId, + 'receive_date' => '20120511', + 'total_amount' => 100.00, + 'financial_type_id' => $this->_financialTypeId, + 'non_deductible_amount' => 10.00, + 'fee_amount' => 5.00, + 'net_amount' => 95.00, + 'source' => 'SSF', + 'contribution_status_id' => 1, + ); + $this->_processorParams = array( + 'domain_id' => 1, + 'name' => 'Dummy', + 'payment_processor_type_id' => 10, + 'financial_account_id' => 12, + 'is_active' => 1, + 'user_name' => '', + 'url_site' => 'http://dummy.com', + 'url_recur' => 'http://dummy.com', + 'billing_mode' => 1, + ); + $this->_pageParams = array( + 'title' => 'Test Contribution Page', + 'financial_type_id' => 1, + 'currency' => 'USD', + 'financial_account_id' => 1, + 'payment_processor' => $paymentProcessor->id, + 'is_active' => 1, + 'is_allow_other_amount' => 1, + 'min_amount' => 10, + 'max_amount' => 1000, + ); + $instruments = $this->callAPISuccess('contribution', 'getoptions', array('field' => 'payment_instrument_id')); + $this->paymentInstruments = $instruments['values']; + } + + /** + * Clean up after each test. + */ + public function tearDown() { + $this->quickCleanUpFinancialEntities(); + } + + /** + * Test the submit function on the contribution page. + */ + public function testSubmit() { + $form = new CRM_Contribute_Form_Contribution(); + $form->testSubmit(array( + 'total_amount' => 50, + 'financial_type_id' => 1, + 'receive_date' => '04/21/2015', + 'receive_date_time' => '11:27PM', + 'contact_id' => $this->_individualId, + 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), + )); + $this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1); + } + + /** + * Test the submit function on the contribution page. + */ + public function testSubmitCreditCard() { + $form = new CRM_Contribute_Form_Contribution(); + $form->testSubmit(array( + 'total_amount' => 50, + 'financial_type_id' => 1, + 'receive_date' => '04/21/2015', + 'receive_date_time' => '11:27PM', + 'contact_id' => $this->_individualId, + 'payment_instrument_id' => array_search('Credit Card', $this->paymentInstruments), + )); + $this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1); + } + + /** + * Test the submit function on the contribution page. + */ + public function testSubmitEmailReceipt() { + $form = new CRM_Contribute_Form_Contribution(); + require_once 'CiviTest/CiviMailUtils.php'; + $mut = new CiviMailUtils($this, TRUE); + $form->testSubmit(array( + 'total_amount' => 50, + 'financial_type_id' => 1, + 'receive_date' => '04/21/2015', + 'receive_date_time' => '11:27PM', + 'contact_id' => $this->_individualId, + 'is_email_receipt' => TRUE, + 'from_email_address' => 'test@test.com', + )); + $this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1); + $mut->checkMailLog(array( + '

Please print this receipt for your records.

', + ) + ); + $mut->stop(); + } +}