CRM-18110-test added test.
authorKarinG <karin@semper-it.com>
Mon, 25 Apr 2016 19:49:07 +0000 (13:49 -0600)
committerKarinG <karin@semper-it.com>
Mon, 25 Apr 2016 19:59:26 +0000 (13:59 -0600)
tests/phpunit/CRM/Contribute/Form/ContributionTest.php

index c4bdeb1b45ddae7f3cd765950635415f20fbc4d5..35c0cbd89db0e76958d6ba5bbc66259b82647031 100644 (file)
@@ -617,6 +617,29 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase {
     $this->assertEquals($note['note'], 'Super cool and interesting stuff');
   }
 
+  /**
+   * Test that if a negative contribution is entered it does not get reset to $0
+   */
+  public function testEnterNegativeContribution() {
+    $form = new CRM_Contribute_Form_Contribution();
+    $form->testSubmit(array(
+      'total_amount' => -5,
+      'financial_type_id' => 1,
+      'receive_date' => '04/24/2016',
+      'receive_date_time' => '11:27PM',
+      'contact_id' => $this->_individualId,
+      'payment_instrument_id' => array_search('Check', $this->paymentInstruments),
+      'contribution_status_id' => 1,
+    ),
+      CRM_Core_Action::ADD);
+    $this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1);
+
+    $contribution = $this->callAPISuccessGetSingle('Contribution', array(
+      'contact_id' => $this->_individualId,
+    ));
+    $this->assertEquals(-5, $contribution['total_amount']);
+  }
+
   /**
    * Test the submit function on the contribution page.
    */