Unit test for CRM-20676 fix
authordeb.monish <monish.deb@jmaconsulting.biz>
Thu, 8 Feb 2018 05:30:13 +0000 (11:00 +0530)
committerdeb.monish <monish.deb@jmaconsulting.biz>
Thu, 8 Feb 2018 05:30:13 +0000 (11:00 +0530)
tests/phpunit/CRM/Member/Form/MembershipTest.php

index 023c4ad9046a517e75e83def31b4c1106ab280a3..c0cf2a51526543ac87420d3aebd9a857d911c433 100644 (file)
@@ -1296,6 +1296,23 @@ Expires: ',
     $this->assertEquals(50.00, $lineItem['line_total']);
     $this->assertEquals(5.00, $lineItem['tax_amount']);
 
+    // Simply save the 'Edit Contribution' form
+    $form = new CRM_Contribute_Form_Contribution();
+    $form->_context = 'membership';
+    $form->_values = $this->callAPISuccessGetSingle('Contribution', array('id' => $lineItem['contribution_id'], 'return' => array('total_amount', 'net_amount', 'fee_amount', 'tax_amount')));
+    $form->testSubmit(array(
+      'contact_id' => $this->_individualId,
+      'id' => $lineItem['contribution_id'],
+      'financial_type_id' => 2,
+      'contribution_status_id' => CRM_Core_Pseudoconstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'),
+    ),
+    CRM_Core_Action::UPDATE);
+
+    // ensure that the line-item values got unaffected
+    $lineItem = $this->callAPISuccessGetSingle('LineItem', array('entity_id' => $membership['id'], 'entity_table' => 'civicrm_membership'));
+    $this->assertEquals(1, $lineItem['qty']);
+    $this->assertEquals(5.00, $lineItem['tax_amount']); // ensure that tax amount is not changed
+
     // reset the price options static variable so not leave any dummy data, that might hamper other unit tests
     \Civi::$statics['CRM_Price_BAO_PriceField']['priceOptions'] = NULL;
     $this->disableTaxAndInvoicing();