[php8-compact] Fix PDF Letter Test by ensuring that all actual DB fields are in...
authorSeamus Lee <seamuslee001@gmail.com>
Sun, 13 Jun 2021 22:59:20 +0000 (22:59 +0000)
committerSeamus Lee <seamuslee001@gmail.com>
Sun, 13 Jun 2021 23:13:29 +0000 (23:13 +0000)
Remove uncessary function call

CRM/Utils/Token.php
tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php

index 2dd76bf4f84a722f2d980874003b69b5a85c02d3..ce10fce61cb53373164098536cb69aee4950a627 100644 (file)
@@ -1559,10 +1559,16 @@ class CRM_Utils_Token {
   protected static function _buildContributionTokens() {
     $key = 'contribution';
     if (self::$_tokens[$key] == NULL) {
-      self::$_tokens[$key] = array_keys(array_merge(CRM_Contribute_BAO_Contribution::exportableFields('All'),
-        ['campaign', 'financial_type'],
+      $tokens = array_merge(CRM_Contribute_BAO_Contribution::exportableFields('All'),
+        ['campaign' => [], 'financial_type' => [], 'payment_instrument' => []],
         self::getCustomFieldTokens('Contribution')
-      ));
+      );
+      foreach ($tokens as $token) {
+        if (!empty($token['name'])) {
+          $tokens[$token['name']] = [];
+        }
+      }
+      self::$_tokens[$key] = array_keys($tokens);
     }
   }
 
@@ -1680,7 +1686,6 @@ class CRM_Utils_Token {
       //early return
       return $str;
     }
-    self::_buildContributionTokens();
 
     // here we intersect with the list of pre-configured valid tokens
     // so that we remove anything we do not recognize
index 8fc99b14f8beac9ed85cc90d47eba917b5e6bf73..7b9cfa124fd9fb99403570dff97dd731a0a5844d 100644 (file)
@@ -49,6 +49,7 @@ class CRM_Contribute_Form_Task_PDFLetterCommonTest extends CiviUnitTestCase {
    * @throws \CiviCRM_API3_Exception
    */
   public function tearDown(): void {
+    CRM_Utils_Token::$_tokens['contribution'] = NULL;
     $this->quickCleanUpFinancialEntities();
     $this->quickCleanup(['civicrm_uf_match', 'civicrm_campaign'], TRUE);
     CRM_Utils_Hook::singleton()->reset();