dev/financial#6 Added is template to search screen
authorJaap Jansma <jaap.jansma@civicoop.org>
Mon, 21 Jun 2021 08:15:36 +0000 (10:15 +0200)
committerJaap Jansma <jaap.jansma@civicoop.org>
Mon, 21 Jun 2021 08:15:36 +0000 (10:15 +0200)
tests/phpunit/CRM/Contribute/Form/SearchTest.php

index efcf948ef26372c9584ba6589c778f5d74bc211e..3bc88cf2383a71cd1f427f1c2aa4ad38adec243a 100644 (file)
@@ -511,6 +511,28 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       'contribution_status_id' => 5,
       'financial_type_id' => "Donation",
     ]);
+    // Create a template contribution.
+    $TemplateContribution = $this->callAPISuccess('Contribution', 'create', [
+      'financial_type_id' => 'Donation',
+      'total_amount' => 11,
+      'receive_date' => date('Ymd'),
+      'receive_date_time' => NULL,
+      'payment_instrument_id' => 1,
+      'contribution_status_id' => 1,
+      'contact_id' => $this->ids['Contact']['contactID1'],
+      'contribution_recur_id' => $ContributionRecur1['id'],
+      'is_template' => 1
+    ]);
+    $params = [
+      'to_financial_account_id' => 1,
+      'status_id' => 1,
+      'contribution_id' => $TemplateContribution['id'],
+      'payment_instrument_id' => 1,
+      'card_type_id' => 1,
+      'total_amount' => 11,
+    ];
+    CRM_Core_BAO_FinancialTrxn::create($params);
+    // Create a normal contribution
     $Contribution1 = $this->callAPISuccess('Contribution', 'create', [
       'financial_type_id' => 'Donation',
       'total_amount' => 11,
@@ -592,6 +614,13 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
         'expected_contact' => [],
         'expected_qill' => "Recurring Contribution Status = 'Cancelled'",
       ],
+      // Case 4: Search for contributions with is_template = 1
+      'in_progress_search' => [
+        'form_value' => ['contribution_is_template' => 1],
+        'expected_count' => 1,
+        'expected_contact' => ['Mr. Joe Miller II'],
+        'expected_qill' => "Is a Template Contribution = \"1\"",
+      ],
       'trxn_id_search' => [
         'form_value' => ['contribution_recur_trxn_id' => 'a transaction'],
         'expected_count' => 1,