Api3 - Add uf_user contact search param
authorColeman Watts <coleman@civicrm.org>
Wed, 5 Dec 2018 03:53:19 +0000 (22:53 -0500)
committerColeman Watts <coleman@civicrm.org>
Wed, 5 Dec 2018 03:53:19 +0000 (22:53 -0500)
api/v3/Contact.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/ContactTest.php

index 5e2dddc1b2009c43def73987aa6b6f7a23be0e93..a79e16f4231bcc1331071c799812929fdf78743d 100644 (file)
@@ -375,6 +375,10 @@ function _civicrm_api3_contact_get_spec(&$params) {
       'table' => 'civicrm_tag',
     ),
   );
+  $params['uf_user'] = array(
+    'title' => 'CMS User',
+    'type' => CRM_Utils_Type::T_BOOLEAN,
+  );
   $params['birth_date_low'] = array('name' => 'birth_date_low', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Birth Date is equal to or greater than'));
   $params['birth_date_high'] = array('name' => 'birth_date_high', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Birth Date is equal to or less than'));
   $params['deceased_date_low'] = array('name' => 'deceased_date_low', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Deceased Date is equal to or greater than'));
index 76a9d3f5c7553f5f337d64dd19c51a064228e9d8..b80cff1e644eb92f89efeec8f04b5b688a1bab9f 100644 (file)
@@ -140,7 +140,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   public $setupIDs = array();
 
   /**
-   * PHPUnit Mock Mecthod to use.
+   * PHPUnit Mock Method to use.
    *
    * @var string
    */
index fead0ec3838e00b410bad16aa774501d4c0a87c2..f56fd7aac01b55b73e2cc55aed31c69cc6c37f2c 100644 (file)
@@ -2061,6 +2061,13 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       'id' => '@user:exampleUser',
     ));
     $this->assertEquals('testGetByUsername', $result['values'][$cid]['first_name']);
+
+    // Check search of contacts with & without uf records
+    $result = $this->callAPISuccess('Contact', 'get', ['uf_user' => 1]);
+    $this->assertArrayHasKey($cid, $result['values']);
+
+    $result = $this->callAPISuccess('Contact', 'get', ['uf_user' => 0]);
+    $this->assertArrayNotHasKey($cid, $result['values']);
   }
 
   /**