Skip to content

Commit

Permalink
Merge pull request #13742 from jitendrapurohit/core-771
Browse files Browse the repository at this point in the history
dev/core#771 - Smart group with uf_group_id does not load contacts wi…
  • Loading branch information
eileenmcnaughton authored Mar 18, 2019
2 parents fb5f8d7 + ce023e5 commit 9b9ba5a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions CRM/Contact/BAO/SavedSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ public static function saveSkippedElement(&$queryParams, $formValues) {
'operator',
'component_mode',
'display_relationship_type',
'uf_group_id',
);
foreach ($specialElements as $element) {
if (!empty($formValues[$element])) {
Expand Down
31 changes: 31 additions & 0 deletions tests/phpunit/CRM/Contact/BAO/SavedSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,37 @@ public function testDateRange() {
$this->assertEquals('01/01/2009', $result['participant_register_date_low']);
$this->assertEquals('01/01/2018', $result['participant_register_date_high']);
}

/**
* Test if skipped elements are correctly
* stored and retrieved as formvalues.
*/
public function testSkippedElements() {
$relTypeID = $this->relationshipTypeCreate();
$savedSearch = new CRM_Contact_BAO_SavedSearch();
$formValues = array(
'operator' => 'AND',
'title' => 'testsmart',
'radio_ts' => 'ts_all',
'component_mode' => CRM_Contact_BAO_Query::MODE_CONTACTS,
'display_relationship_type' => "{$relTypeID}_a_b",
'uf_group_id' => 1,
);
$queryParams = array();
CRM_Contact_BAO_SavedSearch::saveSkippedElement($queryParams, $formValues);
$savedSearch->form_values = serialize($queryParams);
$savedSearch->save();

$result = CRM_Contact_BAO_SavedSearch::getFormValues(CRM_Core_DAO::singleValueQuery('SELECT LAST_INSERT_ID()'));
$expectedResult = array(
'operator' => 'AND',
'component_mode' => CRM_Contact_BAO_Query::MODE_CONTACTS,
'display_relationship_type' => "{$relTypeID}_a_b",
'uf_group_id' => 1,
);
$this->checkArrayEquals($result, $expectedResult);
}

/**
* Test if relative dates are stored correctly
* in civicrm_saved_search table.
Expand Down

0 comments on commit 9b9ba5a

Please sign in to comment.