Skip to content

Commit

Permalink
Add in unit test of code being altered by #15826
Browse files Browse the repository at this point in the history
  • Loading branch information
seamuslee001 committed Nov 17, 2019
1 parent 0644886 commit 197e72c
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions tests/phpunit/CRM/Dedupe/DedupeFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,34 @@ public function testCustomRuleWithAddress() {

}

/**
* 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.
*
Expand Down Expand Up @@ -311,15 +339,15 @@ protected function setupForGroupDedupe() {
'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',
'last_name' => 'hood',
'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',
Expand Down

0 comments on commit 197e72c

Please sign in to comment.