Towards CRM-20155 remove duplicate calls to dedupe functions.
[civicrm-core.git] / tests / phpunit / api / v3 / ContactTest.php
index 8e9c020395fe7d39d9969b252eada642c172131a..406d328fbb52831363de02ca5c7b680de865b4f0 100644 (file)
@@ -2991,19 +2991,15 @@ class api_v3_ContactTest extends CiviUnitTestCase {
    * Test the duplicate check function.
    */
   public function testDuplicateCheck() {
-    $this->callAPISuccess('Contact', 'create', array(
+    $harry = array(
       'first_name' => 'Harry',
       'last_name' => 'Potter',
       'email' => 'harry@hogwarts.edu',
       'contact_type' => 'Individual',
-    ));
+    );
+    $this->callAPISuccess('Contact', 'create', $harry);
     $result = $this->callAPISuccess('Contact', 'duplicatecheck', array(
-      'match' => array(
-        'first_name' => 'Harry',
-        'last_name' => 'Potter',
-        'email' => 'harry@hogwarts.edu',
-        'contact_type' => 'Individual',
-      ),
+      'match' => $harry,
     ));
 
     $this->assertEquals(1, $result['count']);
@@ -3016,6 +3012,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       ),
     ));
     $this->assertEquals(0, $result['count']);
+    $this->callAPIFailure('Contact', 'create', array_merge($harry, array('dupe_check' => 1)));
   }
 
   public function testGetByContactType() {
@@ -3370,4 +3367,12 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $this->callAPISuccess('contact', 'delete', array('id' => $created_contact_id, 'skip_undelete' => TRUE));
   }
 
+  public function testLoggedInUserAPISupportToken() {
+    $description = "Get contact id of the current logged in user";
+    $subFile = "ContactIDOfLoggedInUserContactAPI";
+    $cid = $this->createLoggedInUser();
+    $contact = $this->callAPIAndDocument('contact', 'get', array('id' => 'user_contact_id'), __FUNCTION__, __FILE__, $description, $subFile);
+    $this->assertEquals($cid, $contact['id']);
+  }
+
 }