Add a unit test to ensure that check_number when submitted to the form as contributio...
authorSeamus Lee <seamuslee001@gmail.com>
Tue, 10 Sep 2019 23:22:02 +0000 (09:22 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Tue, 10 Sep 2019 23:22:02 +0000 (09:22 +1000)
tests/phpunit/CRM/Batch/Form/EntryTest.php

index 9967cebfdecbb27ff72eacb3f7f5789cfeb1d17b..6b730b171bc1d613aecf8018cf57ebe0d0e8530e 100644 (file)
@@ -218,7 +218,7 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase {
     $params = $this->getContributionData();
     $this->assertTrue($form->testProcessContribution($params));
     $result = $this->callAPISuccess('contribution', 'get', ['return' => 'total_amount']);
-    $this->assertEquals(2, $result['count']);
+    $this->assertEquals(3, $result['count']);
     foreach ($result['values'] as $contribution) {
       $this->assertEquals($this->callAPISuccess('line_item', 'getvalue', [
         'contribution_id' => $contribution['id'],
@@ -226,6 +226,11 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase {
 
       ]), $contribution['total_amount']);
     }
+    $checkResult = $this->callAPISuccess('Contribution', 'get', ['check_number' => ['IS NOT NULL' => 1]]);
+    $this->assertEquals(1, $checkResult['count']);
+    $entityFinancialTrxn = $this->callAPISuccess('EntityFinancialTrxn', 'get', ['entity_table' => 'civicrm_contribution', 'entity_id' => $checkResult['id']]);
+    $financialTrxn = $this->callAPISuccess('FinancialTrxn', 'get', ['id' => $entityFinancialTrxn['values'][$entityFinancialTrxn['id']]['financial_trxn_id']]);
+    $this->assertEquals('1234', $financialTrxn['values'][$financialTrxn['id']]['check_number']);
   }
 
   /**
@@ -373,8 +378,17 @@ class CRM_Batch_Form_EntryTest extends CiviUnitTestCase {
           'check_number' => NULL,
           'contribution_status_id' => 1,
         ],
+        3 => [
+          'financial_type' => 1,
+          'total_amount' => $this->formatMoneyInput(1500.15),
+          'receive_date' => '2013-07-24',
+          'receive_date_time' => NULL,
+          'payment_instrument' => 4,
+          'contribution_check_number' => '1234',
+          'contribution_status_id' => 1,
+        ],
       ],
-      'actualBatchTotal' => $this->formatMoneyInput(3000.30),
+      'actualBatchTotal' => $this->formatMoneyInput(4500.45),
 
     ];
   }