case 'civicrm_address':
$id = 'contact_id';
- $on[] = 't1.location_type_id = t2.location_type_id';
- $innerJoinClauses[] = 't1.location_type_id = t2.location_type_id';
if (!empty($this->params['civicrm_address']['location_type_id'])) {
$locTypeId = CRM_Utils_Type::escape($this->params['civicrm_address']['location_type_id'], 'Integer', FALSE);
if ($locTypeId) {
$this->assertEquals(count($this->contactIDs), 7, 'Check for number of contacts.');
}
- /**
- * @return array|int
- * @throws \CRM_Core_Exception
- */
- protected function createRuleGroup() {
- $ruleGroup = $this->callAPISuccess('RuleGroup', 'create', [
- 'contact_type' => 'Individual',
- 'threshold' => 8,
- 'used' => 'General',
- 'name' => 'TestRule',
- 'title' => 'TestRule',
- 'is_reserved' => 0,
- ]);
- return $ruleGroup;
- }
-
}
], $pairs);
}
+ /**
+ * Test that location type is ignored when deduping by postal address.
+ *
+ * @throws \CRM_Core_Exception
+ */
+ public function testGetMatchesIgnoreLocationType() {
+ $contact1 = $this->individualCreate();
+ $contact2 = $this->individualCreate();
+ $this->callAPISuccess('address', 'create', [
+ 'contact_id' => $contact1,
+ 'state_province_id' => 1049,
+ 'location_type_id' => 1,
+ ]);
+ $this->callAPISuccess('address', 'create', [
+ 'contact_id' => $contact2,
+ 'state_province_id' => 1049,
+ 'location_type_id' => 2,
+ ]);
+ $ruleGroup = $this->createRuleGroup();
+ $this->callAPISuccess('Rule', 'create', [
+ 'dedupe_rule_group_id' => $ruleGroup['id'],
+ 'rule_table' => 'civicrm_address',
+ 'rule_field' => 'state_province_id',
+ 'rule_weight' => 8,
+ ]);
+ $dupeCount = $this->callAPISuccess('Dedupe', 'getduplicates', [
+ 'rule_group_id' => $ruleGroup['id'],
+ ])['count'];
+ $this->assertEquals($dupeCount, 1);
+ }
+
/**
* Test results are returned when criteria are passed in.
*
}
}
+ /**
+ * @return array|int
+ * @throws \CRM_Core_Exception
+ */
+ protected function createRuleGroup() {
+ $ruleGroup = $this->callAPISuccess('RuleGroup', 'create', [
+ 'contact_type' => 'Individual',
+ 'threshold' => 8,
+ 'used' => 'General',
+ 'name' => 'TestRule',
+ 'title' => 'TestRule',
+ 'is_reserved' => 0,
+ ]);
+ return $ruleGroup;
+ }
+
/**
* Generic create test.
*