Skip to content

Commit

Permalink
Api3 - Add uf_user contact search param
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Dec 5, 2018
1 parent d9f3e10 commit 8d475ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions api/v3/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit/api/v3/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand Down

0 comments on commit 8d475ce

Please sign in to comment.