* @throws \Exception
*/
public function testUnsupervisedDupes() {
- // make dupe checks based on based on following contact sets:
+ // make dupe checks based on following contact sets:
// FIRST - LAST - EMAIL
// ---------------------------------
// robin - hood - robin@example.com
$this->assertEquals(count($foundDupes), 3, 'Check Individual-Fuzzy dupe rule for dupesInGroup().');
}
+ /**
+ * Test duplicate contact retrieval with 2 email fields.
+ */
+ public function testUnsupervisedWithTwoEmailFields() {
+ $this->setupForGroupDedupe();
+ $emails = [
+ ['hood@example.com', ''],
+ ['', 'hood@example.com'],
+ ];
+ for ($i = 0; $i < 2; $i++) {
+ $fields = [
+ 'first_name' => 'robin',
+ 'last_name' => 'hood',
+ 'email-1' => $emails[$i][0],
+ 'email-2' => $emails[$i][1],
+ ];
+ $dedupeParams = CRM_Dedupe_Finder::formatParams($fields, 'Individual');
+ $dedupeResults = CRM_Dedupe_Finder::dupesByParams($dedupeParams, 'Individual');
+ $this->assertEquals(count($dedupeResults), 1);
+ }
+ }
+
/**
* Test that a rule set to is_reserved = 0 works.
*
}
+ /**
+ * 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.
+ */
+ public function testInclusiveRule() {
+ $this->setupForGroupDedupe();
+
+ $ruleGroup = $this->callAPISuccess('RuleGroup', 'create', [
+ 'contact_type' => 'Individual',
+ 'threshold' => 8,
+ 'used' => 'General',
+ 'name' => 'TestRule',
+ 'title' => 'TestRule',
+ 'is_reserved' => 0,
+ ]);
+ $rules = [];
+ foreach (['first_name', 'last_name'] as $field) {
+ $rules[$field] = $this->callAPISuccess('Rule', 'create', [
+ 'dedupe_rule_group_id' => $ruleGroup['id'],
+ 'rule_table' => 'civicrm_contact',
+ 'rule_weight' => 4,
+ 'rule_field' => $field,
+ ]);
+ }
+ $foundDupes = CRM_Dedupe_Finder::dupesInGroup($ruleGroup['id'], $this->groupID);
+ $this->assertEquals(4, count($foundDupes));
+ CRM_Dedupe_Finder::dupes($ruleGroup['id']);
+ }
+
/**
* Test the supervised dedupe rule against a group.
*
'email' => 'robin@example.com',
'contact_type' => 'Individual',
'birth_date' => '2016-01-01',
- 'api.Address.create' => ['location_type_id' => 'Billing', 'postal_code' => '99999'],
+ 'api.Address.create' => ['street_address' => '123 Happy world', 'location_type_id' => 'Billing', 'postal_code' => '99999'],
],
[
'first_name' => 'robin',
'email' => 'hood@example.com',
'contact_type' => 'Individual',
'birth_date' => '2016-01-01',
- 'api.Address.create' => ['location_type_id' => 'Billing', 'postal_code' => '99999'],
+ 'api.Address.create' => ['street_address' => '123 Happy World', 'location_type_id' => 'Billing', 'postal_code' => '99999'],
],
[
'first_name' => 'robin',