CRM-17287 Test fix for contribution note
authormonishdeb <monish.deb@webaccessglobal.com>
Mon, 28 Sep 2015 20:24:41 +0000 (01:54 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Mon, 28 Sep 2015 20:43:41 +0000 (02:13 +0530)
----------------------------------------
* CRM-17287: Broken Unit Tests on master
  https://issues.civicrm.org/jira/browse/CRM-17287

CRM/Contribute/Form/Contribution.php
tests/phpunit/CRM/Financial/Page/AjaxTest.php

index 4fab02ad799cf24ee55991c88bf1408526307e00..caa9e9a22b67d48800710bb58ee7282d7741321f 100644 (file)
@@ -1626,6 +1626,10 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       }
       $params['non_deductible_amount'] = $this->calculateNonDeductibleAmount($params, $formValues);
 
+      // we are already handling note below, so to avoid duplicate notes against $contribution
+      if (!empty($params['note']) && !empty($submittedValues['note'])) {
+        unset($params['note']);
+      }
       $contribution = CRM_Contribute_BAO_Contribution::create($params, $ids);
 
       // process associated membership / participant, CRM-4395
@@ -1667,7 +1671,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       );
     }
 
-    if ($contribution->id && isset($submittedValues['note'])) {
+    if ($contribution->id && !empty($submittedValues['note'])) {
       CRM_Contribute_Form_AdditionalInfo::processNote($submittedValues, $this->_contactID, $contribution->id, $this->_noteID);
     }
 
index d7b64e92b4f94f684004109b3f27d3024042a735..687142386488b781d2464aaaefec39a921f59332 100644 (file)
@@ -38,7 +38,7 @@ class CRM_Financial_Page_AjaxTest extends CiviUnitTestCase {
    */
   public function testGetFinancialTransactionsList() {
     $individualID = $this->individualCreate();
-    $this->contributionCreate($individualID);
+    $this->contributionCreate(array('contact_id' => $individualID));
     $batch = $this->callAPISuccess('Batch', 'create', array('title' => 'test', 'status_id' => 'Open'));
     CRM_Core_DAO::executeQuery("
      INSERT INTO civicrm_entity_batch (entity_table, entity_id, batch_id)