Skip to content

Commit

Permalink
dev/core#961 - Contribution page including 2 email fields does not re…
Browse files Browse the repository at this point in the history
…spect dedupe rule.
  • Loading branch information
Jitendra Purohit committed May 15, 2019
1 parent f3171f1 commit 0135a64
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CRM/Dedupe/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ public static function formatParams($fields, $ctype) {
if (preg_match('/(.*)-(Primary-[\d+])$|(.*)-(\d+|Primary)$/', $key, $matches)) {
$return = array_values(array_filter($matches));
$flat[$return[1]] = $value;
// make sure the first occurrence is kept, not the last
$flat[$return[1]] = !isset($flat[$return[1]]) ? $value : $flat[$return[1]];
unset($flat[$key]);
}
}
Expand Down
18 changes: 17 additions & 1 deletion tests/phpunit/CRM/Dedupe/DedupeFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function tearDown() {
* @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
Expand All @@ -58,6 +58,22 @@ public function testUnsupervisedDupes() {
$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();
$fields = [
'first_name' => 'robin',
'last_name' => 'hood',
'email-1' => 'hood@example.com',
'email-2' => '',
];
$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.
*
Expand Down

0 comments on commit 0135a64

Please sign in to comment.