Unverified Commit 904b5887 authored by Seamus Lee's avatar Seamus Lee Committed by GitHub

Merge pull request #16155 from seamuslee001/5.21

#183 Ensure that having a rule where each field is the same w…
parents b5e21a2b 9742d8f3
......@@ -234,6 +234,8 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup {
$query = array_shift($tableQueries);
if ($searchWithinDupes) {
// drop dedupe_copy table just in case if its already there.
$dedupeCopyTemporaryTableObject->drop();
// get prepared to search within already found dupes if $searchWithinDupes flag is set
$dedupeCopyTemporaryTableObject->createWithQuery("SELECT * FROM {$this->temporaryTables['dedupe']} WHERE weight >= {$weightSum}");
......
......@@ -140,6 +140,33 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase {
}
/**
* Test rule from Richard
*/
public function testRuleThreeContactFieldsEqualWeightWIthThresholdtheTotalSumOfAllWeight() {
$this->setupForGroupDedupe();
$ruleGroup = $this->callAPISuccess('RuleGroup', 'create', [
'contact_type' => 'Individual',
'threshold' => 30,
'used' => 'General',
'name' => 'TestRule',
'title' => 'TestRule',
'is_reserved' => 0,
]);
foreach (['first_name', 'last_name', 'birth_date'] as $field) {
$rules[$field] = $this->callAPISuccess('Rule', 'create', [
'dedupe_rule_group_id' => $ruleGroup['id'],
'rule_table' => 'civicrm_contact',
'rule_weight' => 10,
'rule_field' => $field,
]);
}
$foundDupes = CRM_Dedupe_Finder::dupesInGroup($ruleGroup['id'], $this->groupID);
$this->assertEquals(1, count($foundDupes));
}
/**
* Test a custom rule with a non-default field.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment