From 8d475ce984ede690d3f5d3785a37f5c30e64fdea Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 4 Dec 2018 22:53:19 -0500 Subject: [PATCH] Api3 - Add uf_user contact search param --- api/v3/Contact.php | 4 ++++ tests/phpunit/CiviTest/CiviUnitTestCase.php | 2 +- tests/phpunit/api/v3/ContactTest.php | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 5e2dddc1b20..a79e16f4231 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -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')); diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 76a9d3f5c75..b80cff1e644 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -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 */ diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index fead0ec3838..f56fd7aac01 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -2061,6 +2061,13 @@ public function testContactGetByUsername() { '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']); } /**