From: eileenmcnaughton Date: Wed, 29 Jul 2015 08:44:05 +0000 (+0000) Subject: CRM-16923 test to demonstrate point of failure X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7bc789a574862b43b19293ce05a095c95d7cf928;p=civicrm-core.git CRM-16923 test to demonstrate point of failure --- diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index fb5b991388..eb53397d8c 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -39,18 +39,21 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_ContributionPage { /** - * Takes an associative array and creates a contribution page object. + * Creates a contribution page. * * @param array $params - * (reference ) an assoc array of name/value pairs. * * @return CRM_Contribute_DAO_ContributionPage */ - public static function &create(&$params) { + public static function create($params) { $financialTypeId = NULL; if (!empty($params['id']) && !CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $params['id'], NULL, 1)) { $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $params['id'], 'financial_type_id'); } + + if (isset($params['payment_processor']) && is_array($params['payment_processor'])) { + $params['payment_processor'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params['payment_processor']); + } $hook = empty($params['id']) ? 'create' : 'edit'; CRM_Utils_Hook::pre($hook, 'ContributionPage', CRM_Utils_Array::value('id', $params), $params); $dao = new CRM_Contribute_DAO_ContributionPage(); diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index 009d3c9684..92d33434eb 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -149,6 +149,45 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->callAPISuccess('contribution', 'getsingle', array('contribution_page_id' => $this->_ids['contribution_page'])); } + /** + * Test process with instant payment when more than one configured for the page. + * + * CRM-16923 + */ + public function testSubmitRecurMultiProcessorInstantPayment() { + $this->setUpContributionPage(); + $this->setupPaymentProcessor(); + $paymentProcessor2ID = $this->paymentProcessorCreate(array( + 'payment_processor_type_id' => 'Dummy', + 'name' => 'processor 2', + 'class_name' => 'Payment_Dummy', + 'billing_mode' => 1, + )); + $dummyPP = Civi\Payment\System::singleton()->getById($paymentProcessor2ID); + $dummyPP->setDoDirectPaymentResult(array('payment_status_id' => 1, 'trxn_id' => 'create_first_success')); + $this->callAPISuccess('ContributionPage', 'create', array( + 'id' =>$this->_ids['contribution_page'], + 'payment_processor' => array($paymentProcessor2ID, $this->_ids['payment_processor']) + )); + + $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, + 'is_recur' => 1, + 'frequency_interval' => 1, + 'frequency_unit' => 'month', + 'payment_processor_id' => $paymentProcessor2ID, + ); + + $this->callAPISuccess('contribution_page', 'submit', $submitParams); + $this->callAPISuccess('contribution', 'getsingle', array( + 'contribution_page_id' => $this->_ids['contribution_page'], + 'contribution_status_id' => 1, + )); + } /** * Test submit with a membership block in place. */ @@ -238,7 +277,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { 'billing_middle_name' => 'Goat', 'billing_last_name' => 'Gruff', 'selectMembership' => $this->_ids['membership_type'], - 'payment_processor_id' => 1, + 'payment_processor_id' => $this->_paymentProcessor['id'], 'credit_card_number' => '4111111111111111', 'credit_card_type' => 'Visa', 'credit_card_exp_date' => array('M' => 9, 'Y' => 2040),