Merge pull request #15330 from mattwire/paymentprocessor_testmodelivemode
[civicrm-core.git] / tests / phpunit / CRM / Dedupe / DedupeFinderTest.php
index b0318c12a0fddd65abe3ca83ab5d26a5ddbdc429..0666a70854c47071e023147ff864ed3e5970407b 100644 (file)
@@ -140,6 +140,33 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase {
 
   }
 
+  /**
+   * 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.
    */