From 8188f8ec49baa1c3c360e639288dcd18d49e40e0 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 15 Jun 2017 08:09:11 +1000 Subject: [PATCH] CRM-20253 Add test to ensure that email receipts aren't sent when not requested on backend form --- .../CRM/Contribute/Form/ContributionTest.php | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index 1f838839b5..c9034aeb8c 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -241,6 +241,70 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { $this->assertTrue(empty($contact['source'])); } + /** + * Test the submit function on the contribution page. + */ + public function testSubmitCreditCardNoReceipt() { + $mut = new CiviMailUtils($this, TRUE); + $mut->clearMessages(0); + $form = new CRM_Contribute_Form_Contribution(); + $paymentProcessorID = $this->paymentProcessorCreate(array('is_test' => 0)); + $form->_mode = 'Live'; + $error = FALSE; + try { + $form->testSubmit(array( + 'total_amount' => 60, + 'financial_type_id' => 1, + 'receive_date' => '04/21/2015', + 'receive_date_time' => '11:27PM', + 'contact_id' => $this->_individualId, + 'contribution_status_id' => 1, + 'credit_card_number' => 4444333322221111, + 'cvv2' => 123, + 'credit_card_exp_date' => array( + 'M' => 9, + 'Y' => 2025, + ), + 'credit_card_type' => 'Visa', + 'billing_first_name' => 'Junko', + 'billing_middle_name' => '', + 'billing_last_name' => 'Adams', + 'billing_street_address-5' => '790L Lincoln St S', + 'billing_city-5' => 'Maryknoll', + 'billing_state_province_id-5' => 1031, + 'billing_postal_code-5' => 10545, + 'billing_country_id-5' => 1228, + 'frequency_interval' => 1, + 'frequency_unit' => 'month', + 'installments' => '', + 'hidden_AdditionalDetail' => 1, + 'hidden_Premium' => 1, + 'from_email_address' => '"civi45" ', + 'receipt_date' => '', + 'receipt_date_time' => '', + 'payment_processor_id' => $paymentProcessorID, + 'currency' => 'USD', + 'source' => 'bob sled race', + ), CRM_Core_Action::ADD); + } + catch (Civi\Payment\Exception\PaymentProcessorException $e) { + $error = TRUE; + } + + $this->callAPISuccessGetCount('Contribution', array( + 'contact_id' => $this->_individualId, + 'contribution_status_id' => $error ? 'Failed' : 'Completed', + 'payment_instrument_id' => $this->callAPISuccessGetValue('PaymentProcessor', array( + 'return' => 'payment_instrument_id', + 'id' => $paymentProcessorID, + )), + ), 1); + $contact = $this->callAPISuccessGetSingle('Contact', array('id' => $this->_individualId)); + $this->assertTrue(empty($contact['source'])); + $mut->assertMailLogEmpty(); + $mut->stop(); + } + /** * Test the submit function on the contribution page. */ -- 2.25.1