hook_civicrm_links - Add exception for financialItem.batch.row
authorTim Otten <totten@civicrm.org>
Tue, 3 Oct 2023 04:44:13 +0000 (21:44 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 3 Oct 2023 04:44:59 +0000 (21:44 -0700)
tests/events/hook_civicrm_links.evch.php

index cd1329fee0ef38d992907dca0f676d0a81eb821f..0c62b8d6bf4da7041afba2617081cffaf7f5d83d 100644 (file)
@@ -30,6 +30,7 @@ return new class() extends EventCheck implements HookInterface {
   protected $grandfatheredNoUrl = [
     'basic.CRM_Core_BAO_LocationType.page::CRM_Core_BAO_LocationType',
     'case.tab.row::Activity',
+    'financialItem.batch.row::FinancialItem',
     'group.selector.row::Group',
     'job.manage.action::Job',
     'membershipType.manage.action::MembershipType',
@@ -37,6 +38,16 @@ return new class() extends EventCheck implements HookInterface {
     'basic.CRM_Core_BAO_MessageTemplate.page::CRM_Core_BAO_MessageTemplate',
   ];
 
+  /**
+   * These are deviant values with appear as `$link['bit']` fields. They are documented
+   * (and generally practiced) as integers.
+   *
+   * @var \string[][]
+   */
+  protected $grandfatheredInvalidBits = [
+    'financialItem.batch.row' => ['view', 'assign'],
+  ];
+
   /**
    * These variants have anomalous keys that are not documented and do not
    * appear in most flavors of "hook_civicrm_links".
@@ -110,7 +121,12 @@ return new class() extends EventCheck implements HookInterface {
         $this->assertType('string', $link['extra'], "$msg: extra should be a string");
       }
       if (isset($link['bit'])) {
-        $this->assertType('integer', $link['bit'], "$msg: bit should be an int");
+        if (in_array($link['bit'], $this->grandfatheredInvalidBits[$op] ?? [])) {
+          // Exception
+        }
+        else {
+          $this->assertType('integer', $link['bit'], "$msg: bit should be an int" . $link['bit']);
+        }
       }
       if (isset($link['ref'])) {
         $this->assertType('string', $link['ref'], "$msg: ref should be an string");