From 1d5b48fb76de42ceb8e6636c54e5de6cfe549589 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Wed, 11 Sep 2019 09:22:02 +1000 Subject: [PATCH] Add a unit test to ensure that check_number when submitted to the form as contribution_check_number is correctly saved into the financial Transaction --- tests/phpunit/CRM/Batch/Form/EntryTest.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CRM/Batch/Form/EntryTest.php b/tests/phpunit/CRM/Batch/Form/EntryTest.php index 9967cebfde..6b730b171b 100644 --- a/tests/phpunit/CRM/Batch/Form/EntryTest.php +++ b/tests/phpunit/CRM/Batch/Form/EntryTest.php @@ -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), ]; } -- 2.25.1