Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-20253 Add another test using dummy processor and switch noReceipt… #10508

Merged
merged 1 commit into from
Jun 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 67 additions & 3 deletions tests/phpunit/CRM/Contribute/Form/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,78 @@ public function testSubmitCreditCardPayPal() {
$mut->stop();
}

/**
* Test the submit function on the contribution page
*/
public function testSubmitCreditCardWithEmailReceipt() {
$mut = new CiviMailUtils($this, TRUE);
$mut->clearMessages(0);
$form = new CRM_Contribute_Form_Contribution();
$form->_mode = 'Live';
$error = FALSE;
try {
$form->testSubmit(array(
'total_amount' => 50,
'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" <civi45@civicrm.com>',
'is_email_receipt' => TRUE,
'receipt_date' => '',
'receipt_date_time' => '',
'payment_processor_id' => $this->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' => $this->paymentProcessorID,
)),
), 1);
$contact = $this->callAPISuccessGetSingle('Contact', array('id' => $this->_individualId));
$this->assertTrue(empty($contact['source']));
$msgs = $mut->getAllMessages();
$this->assertEquals(1, count($msgs));
$mut->stop();
}


/**
* 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 {
Expand Down Expand Up @@ -290,7 +354,7 @@ public function testSubmitCreditCardNoReceipt() {
'from_email_address' => '"civi45" <civi45@civicrm.com>',
'receipt_date' => '',
'receipt_date_time' => '',
'payment_processor_id' => $paymentProcessorID,
'payment_processor_id' => $this->paymentProcessorID,
'currency' => 'USD',
'source' => 'bob sled race',
), CRM_Core_Action::ADD);
Expand All @@ -304,7 +368,7 @@ public function testSubmitCreditCardNoReceipt() {
'contribution_status_id' => $error ? 'Failed' : 'Completed',
'payment_instrument_id' => $this->callAPISuccessGetValue('PaymentProcessor', array(
'return' => 'payment_instrument_id',
'id' => $paymentProcessorID,
'id' => $this->paymentProcessorID,
)),
), 1);
$contact = $this->callAPISuccessGetSingle('Contact', array('id' => $this->_individualId));
Expand Down