'civicrm_group',
'civicrm_prevnext_cache',
]);
+ if ($this->hookClass) {
+ // Do this here to flush the entityTables cache on teardown.
+ // it might be a bit expensive to add to every single test
+ // so a bit selectively.
+ $this->hookClass->reset();
+ CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE);
+ }
parent::tearDown();
}
return $cidRefs;
}
+ /**
+ * Test that declaring a custom join for search kit does not break merge.
+ *
+ * @throws \CRM_Core_Exception
+ */
+ public function testMergeWithDeclaredSearchJoin(): void {
+ $this->hookClass->setHook('civicrm_entityTypes', [
+ $this,
+ 'hookEntityTypes',
+ ]);
+ CRM_Core_DAO_AllCoreTables::reinitializeCache(TRUE);
+ $contact1 = $this->individualCreate();
+ $contact2 = $this->individualCreate(['api.Im.create' => ['name' => 'chat_handle']]);
+ $this->callAPISuccess('Contact', 'merge', ['to_keep_id' => $contact1, 'to_remove_id' => $contact2]);
+ }
+
+ /**
+ * Implements hook_civicrm_entityTypes().
+ *
+ * Declare a callback to hookLinkCallBack function.
+ */
+ public function hookEntityTypes(&$entityTypes): void {
+ $entityTypes['CRM_Core_DAO_IM']['links_callback'][] = [$this, 'hookLinkCallBack'];
+ }
+
+ /**
+ * Callback to alter the link to im
+ *
+ * Declare a pseudo-fk between name and IM.name
+ * so it can be joined in SearchKit. This is obviously
+ * artificial but is intended to mimic the pseudo-joins
+ * extensions might use to leverage search kit.
+ *
+ * @param string $className
+ * @param array $links
+ *
+ * @noinspection PhpUnusedParameterInspection
+ */
+ public function hookLinkCallBack(string $className, array &$links): void {
+ $links[] = new CRM_Core_Reference_Basic('civicrm_im', 'name', 'civicrm_contact', 'first_name');
+ }
+
}
* @throws \CiviCRM_API3_Exception
*/
public function tearDown(): void {
- $this->membershipStatusDelete($this->_membershipStatusID);
$this->_membershipStatusID = $this->_membershipTypeID = NULL;
$this->quickCleanUpFinancialEntities();
parent::tearDown();
$this->assertEquals(2, $relatedMembershipsCount, "Related membership count should still be 2, but found $relatedMembershipsCount");
$this->assertMembershipExists($relatedMembership1['id']);
$this->assertMembershipExists($relatedMembership2['id']);
-
- // Clean up: Delete everything!
- $this->membershipDelete($membership['id']);
- $this->membershipStatusDelete($otherStatusID);
}
public function testRelatedMembershipWithContactReferenceCustomField() {