From: DemeritCowboy Date: Wed, 10 Apr 2019 00:59:15 +0000 (-0400) Subject: add test X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=92eadb36cf12cad1484f95dd8246231b75c75278;p=civicrm-core.git add test --- diff --git a/tests/phpunit/CRM/Dedupe/DedupeFinderTest.php b/tests/phpunit/CRM/Dedupe/DedupeFinderTest.php index f559aece3c..65a728c05c 100644 --- a/tests/phpunit/CRM/Dedupe/DedupeFinderTest.php +++ b/tests/phpunit/CRM/Dedupe/DedupeFinderTest.php @@ -89,6 +89,35 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase { } + /** + * Test a custom rule with a non-default field. + */ + public function testCustomRuleWithAddress() { + $this->setupForGroupDedupe(); + + $ruleGroup = $this->callAPISuccess('RuleGroup', 'create', array( + 'contact_type' => 'Individual', + 'threshold' => 10, + 'used' => 'General', + 'name' => 'TestRule', + 'title' => 'TestRule', + 'is_reserved' => 0, + )); + $rules = []; + foreach (array('postal_code') as $field) { + $rules[$field] = $this->callAPISuccess('Rule', 'create', [ + 'dedupe_rule_group_id' => $ruleGroup['id'], + 'rule_table' => 'civicrm_address', + 'rule_weight' => 10, + 'rule_field' => $field, + ]); + } + $foundDupes = CRM_Dedupe_Finder::dupesInGroup($ruleGroup['id'], $this->groupID); + $this->assertEquals(count($foundDupes), 1); + CRM_Dedupe_Finder::dupes($ruleGroup['id']); + + } + /** * Test the supervised dedupe rule against a group. * @@ -260,6 +289,7 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase { 'email' => 'robin@example.com', 'contact_type' => 'Individual', 'birth_date' => '2016-01-01', + 'api.Address.create' => ['location_type_id' => 'Billing', 'postal_code' => '99999'], ), array( 'first_name' => 'robin', @@ -267,6 +297,7 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase { 'email' => 'hood@example.com', 'contact_type' => 'Individual', 'birth_date' => '2016-01-01', + 'api.Address.create' => ['location_type_id' => 'Billing', 'postal_code' => '99999'], ), array( 'first_name' => 'robin',