From: eileen Date: Thu, 29 Nov 2018 23:14:32 +0000 (+1300) Subject: Add unit test improvements to support testing dev/core#397 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ce217e173d621a9ac3229d5a06456878bf9b2653;p=civicrm-core.git Add unit test improvements to support testing dev/core#397 I have marked the test incomplete as we get a fatal error on the actual test for #397 (with or without the proposed fix) but I think if we merge this it makes it easy to complete #397 --- diff --git a/CRM/Dedupe/BAO/RuleGroup.php b/CRM/Dedupe/BAO/RuleGroup.php index dda5bad136..161b8175a1 100644 --- a/CRM/Dedupe/BAO/RuleGroup.php +++ b/CRM/Dedupe/BAO/RuleGroup.php @@ -282,7 +282,6 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { if ($dao->affectedRows() >= 1) { $exclWeightSum[] = substr($fieldWeight, strrpos($fieldWeight, '.') + 1); } - $dao->free(); } else { // its a die situation diff --git a/tests/phpunit/CRM/Dedupe/DedupeFinderTest.php b/tests/phpunit/CRM/Dedupe/DedupeFinderTest.php index 97234c9ef4..947e52f831 100644 --- a/tests/phpunit/CRM/Dedupe/DedupeFinderTest.php +++ b/tests/phpunit/CRM/Dedupe/DedupeFinderTest.php @@ -58,6 +58,11 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase { $this->assertEquals(count($foundDupes), 3, 'Check Individual-Fuzzy dupe rule for dupesInGroup().'); } + /** + * Test that a rule set to is_reserved = 0 works. + * + * There is a different search used dependent on this variable. + */ public function testCustomRule() { $this->setupForGroupDedupe(); @@ -69,8 +74,9 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase { 'title' => 'TestRule', 'is_reserved' => 0, )); - foreach (array('first_name', 'last_name') as $field) { - $this->callAPISuccess('Rule', 'create', [ + $rules = []; + foreach (array('birth_date', '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, @@ -79,6 +85,9 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase { } $foundDupes = CRM_Dedupe_Finder::dupesInGroup($ruleGroup['id'], $this->groupID); $this->assertEquals(count($foundDupes), 4); + $this->markTestIncomplete('This currenctly fails - see https://lab.civicrm.org/dev/core/issues/397'); + CRM_Dedupe_Finder::dupes($ruleGroup['id']); + } /** @@ -216,12 +225,14 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase { 'last_name' => 'hood', 'email' => 'robin@example.com', 'contact_type' => 'Individual', + 'birth_date' => '2016-01-01', ), array( 'first_name' => 'robin', 'last_name' => 'hood', 'email' => 'hood@example.com', 'contact_type' => 'Individual', + 'birth_date' => '2016-01-01', ), array( 'first_name' => 'robin',