From 5961bd47c784cfb7d0e14383d1cfa943eebc5812 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 25 Jun 2015 00:23:41 +1200 Subject: [PATCH] CRM-16417 add test --- tests/phpunit/api/v3/ContributionPageTest.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index d15ca4f53f..75f82eb086 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -255,6 +255,42 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->assertEquals($membership['contact_id'], $contributions['values'][$membershipPayment['contribution_id']]['contact_id']); } + /** + * Test that when a transaction fails the pending contribution remains. + * + * An activity should also be created. CRM-16417. + */ + public function testSubmitPaymentProcessorFailure() { + $this->setUpContributionPage(); + $this->setupPaymentProcessor(); + $this->createLoggedInUser(); + $priceFieldID = reset($this->_ids['price_field']); + $priceFieldValueID = reset($this->_ids['price_field_value']); + $submitParams = array( + 'price_' . $priceFieldID => $priceFieldValueID, + 'id' => (int) $this->_ids['contribution_page'], + 'amount' => 10, + 'payment_processor_id' => 1, + 'credit_card_number' => '4111111111111111', + 'credit_card_type' => 'Visa', + 'credit_card_exp_date' => array('M' => 9, 'Y' => 2008), + 'cvv2' => 123, + ); + + $this->callAPISuccess('contribution_page', 'submit', $submitParams); + $contribution = $this->callAPISuccessGetSingle('contribution', array( + 'contribution_page_id' => $this->_ids['contribution_page'], + 'contribution_status_id' => 2, + )); + + $this->callAPISuccessGetSingle('activity', array( + 'source_record_id' => $contribution['id'], + 'activity_type_id' => 'Failed Payment', + )); + + + } + /** * Test submit recurring membership with immediate confirmation (IATS style) * - we process 2 membership transactions against with a recurring contribution against a contribution page with an immediate -- 2.25.1