From 7538f64d04c889a40fffe51cdde462020794c651 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 6 Sep 2020 07:45:11 +1000 Subject: [PATCH] report#45 Switch out function call CRM_Utils_Array::value and extend test coverage Minor fix for MySQL 8 --- CRM/Contact/BAO/Group.php | 6 +++--- tests/phpunit/CRM/Group/Page/AjaxTest.php | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 5fe886756d..ab328527e0 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -1223,12 +1223,12 @@ WHERE {$whereClause}"; $clauses[] = '`groups`.parents IS NULL'; } - $savedSearch = CRM_Utils_Array::value('savedSearch', $params); + $savedSearch = $params['savedSearch'] ?? NULL; if ($savedSearch == 1) { - $clauses[] = 'groups.saved_search_id IS NOT NULL'; + $clauses[] = '`groups`.saved_search_id IS NOT NULL'; } elseif ($savedSearch == 2) { - $clauses[] = 'groups.saved_search_id IS NULL'; + $clauses[] = '`groups`.saved_search_id IS NULL'; } // only show child groups of a specific parent group diff --git a/tests/phpunit/CRM/Group/Page/AjaxTest.php b/tests/phpunit/CRM/Group/Page/AjaxTest.php index 686e16fc9f..6eb09d8bb1 100644 --- a/tests/phpunit/CRM/Group/Page/AjaxTest.php +++ b/tests/phpunit/CRM/Group/Page/AjaxTest.php @@ -98,7 +98,27 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { } $this->assertEquals(1, $groups['recordsTotal']); $this->assertEquals('not-me-active', $groups['data'][0]['title']); + // Search on just smart groups keeping the title filter + $_GET['savedSearch'] = 1; + try { + CRM_Group_Page_AJAX::getGroupList(); + } + catch (CRM_Core_Exception_PrematureExitException $e) { + $groups = $e->errorData; + } + $this->assertEquals(0, $groups['recordsTotal']); + // Now search on just normal groups keeping the title filter + $_GET['savedSearch'] = 2; + try { + CRM_Group_Page_AJAX::getGroupList(); + } + catch (CRM_Core_Exception_PrematureExitException $e) { + $groups = $e->errorData; + } + $this->assertEquals(1, $groups['recordsTotal']); + $this->assertEquals('not-me-active', $groups['data'][0]['title']); unset($_GET['title']); + unset($_GET['savedSearch']); // check on status $_GET['status'] = 2; -- 2.25.1