CRM-17275 Contact.duplicate api test
authoreileenmcnaugton <eileen@fuzion.co.nz>
Thu, 24 Sep 2015 12:17:48 +0000 (00:17 +1200)
committermonishdeb <monish.deb@webaccessglobal.com>
Wed, 30 Sep 2015 12:50:57 +0000 (18:20 +0530)
tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php
tests/phpunit/api/v3/ContactTest.php

index ffb85d4860a46147c696888b102d29d57797c5a7..8138ad988dc94f0c673ccda1d612cce323d3cecf 100644 (file)
@@ -131,4 +131,5 @@ class CRM_Contact_Imports_Parser_ContactTest extends CiviUnitTestCase {
     $parser->init();
     $this->assertEquals($expectedResult, $parser->import($onDuplicateAction, $values));
   }
+
 }
index 6342641d1f4ac3955e9c9150a5523bd86a672f43..c531525baf25295e94e53c0f07230ac5b2e9f409 100644 (file)
@@ -2708,4 +2708,35 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     }
   }
 
+  /**
+   * Test the duplicate check function.
+   */
+  public function testDuplicateCheck() {
+    $this->callAPISuccess('Contact', 'create', array(
+      'first_name' => 'Harry',
+      'last_name' => 'Potter',
+      'email' => 'harry@hogwarts.edu',
+      'contact_type' => 'Individual',
+    ));
+    $result = $this->callAPISuccess('Contact', 'duplicatecheck', array(
+      'match' => array(
+        'first_name' => 'Harry',
+        'last_name' => 'Potter',
+        'email' => 'harry@hogwarts.edu',
+        'contact_type' => 'Individual',
+      ),
+    ));
+
+    $this->assertEquals(1, $result['count']);
+    $result = $this->callAPISuccess('Contact', 'duplicatecheck', array(
+      'match' => array(
+        'first_name' => 'Harry',
+        'last_name' => 'Potter',
+        'email' => 'no5@privet.drive',
+        'contact_type' => 'Individual',
+      ),
+    ));
+    $this->assertEquals(0, $result['count']);
+  }
+
 }