From: Mathieu Lutfy Date: Thu, 31 Mar 2016 03:26:17 +0000 (-0400) Subject: CRM-18277 : add test & fix for the contact.source field. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=dc0ca56c9218fe4d9555df1894a7d8711b1485b3;p=civicrm-core.git CRM-18277 : add test & fix for the contact.source field. --- diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index 36c221f39d..e006218a3e 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -699,6 +699,12 @@ LEFT JOIN civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co if ($hasBillingField) { $addressParams = array_merge($this->_params, $addressParams); + // CRM-18277 don't let this get passed in because we don't want contribution source to override contact source. + // Ideally we wouldn't just randomly merge everything into addressParams but just pass in a relevant array. + // Note this source field is covered by a unit test. + if (isset($addressParams['source'])) { + unset($addressParams['source']); + } //here we are setting up the billing contact - if different from the member they are already created // but they will get billing details assigned CRM_Contact_BAO_Contact::createProfileContact($addressParams, $fields, diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index b05e88a349..2f89b30ea0 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -222,7 +222,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { 'receipt_date_time' => '', 'payment_processor_id' => $paymentProcessorID, 'currency' => 'USD', - 'source' => '', + 'source' => 'bob sled race', ), CRM_Core_Action::ADD); } catch (Civi\Payment\Exception\PaymentProcessorException $e) { @@ -233,6 +233,8 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { 'contact_id' => $this->_individualId, 'contribution_status_id' => 'Pending', ), 1); + $contact = $this->callAPISuccessGetSingle('Contact', array('id' => $this->_individualId)); + $this->assertEmpty($contact['source']); } /**