report#45 Switch out function call CRM_Utils_Array::value and extend test coverage
authorSeamus Lee <seamuslee001@gmail.com>
Sat, 5 Sep 2020 21:45:11 +0000 (07:45 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Sat, 5 Sep 2020 22:46:50 +0000 (08:46 +1000)
Minor fix for MySQL 8

CRM/Contact/BAO/Group.php
tests/phpunit/CRM/Group/Page/AjaxTest.php

index 5fe886756d202673a50cde90d09fc04f80f41555..ab328527e0bb5a5130d3ec3019e18b3e048c4f7b 100644 (file)
@@ -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
index 686e16fc9f3c12fe8e26d16ec20b90a4293ba440..6eb09d8bb125671efa024ece393a6fdda906a0aa 100644 (file)
@@ -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;