Skip to content
Snippets Groups Projects
Commit da0c54be authored by Eileen McNaughton's avatar Eileen McNaughton
Browse files

#2656 Add test to demonstrate issue / bug

Fix enotice in test

Why didn't this cause it to fail before
parent 93aadf0f
Branches
Tags
No related merge requests found
......@@ -32,6 +32,13 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase {
'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();
}
......@@ -1449,4 +1456,46 @@ WHERE
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');
}
}
......@@ -40,7 +40,6 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
* @throws \CiviCRM_API3_Exception
*/
public function tearDown(): void {
$this->membershipStatusDelete($this->_membershipStatusID);
$this->_membershipStatusID = $this->_membershipTypeID = NULL;
$this->quickCleanUpFinancialEntities();
parent::tearDown();
......@@ -906,10 +905,6 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
$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() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment