From f05770265ef60af4ec4049de6f7669f1b3f04f8a Mon Sep 17 00:00:00 2001 From: Joseph Lacey Date: Wed, 24 Feb 2016 15:49:02 -0500 Subject: [PATCH] Fixing remaining Group Page AJAX PHPUnit tests. --- tests/phpunit/CRM/Group/Page/AjaxTest.php | 273 ++++++++++++---------- 1 file changed, 151 insertions(+), 122 deletions(-) diff --git a/tests/phpunit/CRM/Group/Page/AjaxTest.php b/tests/phpunit/CRM/Group/Page/AjaxTest.php index cbea43d9d1..8daab142e0 100644 --- a/tests/phpunit/CRM/Group/Page/AjaxTest.php +++ b/tests/phpunit/CRM/Group/Page/AjaxTest.php @@ -98,17 +98,19 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { */ public function testGroupEditWithAndWithoutPermission() { $this->setPermissionAndRequest('view all contacts'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(2, $total); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); - $this->assertEquals('not-me-active', $groups[4]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(2, $groups['recordsTotal']); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); + $this->assertEquals('not-me-active', $groups['data'][4]['group_name']); // as per changes made in PR-6822 $this->setPermissionAndRequest(array('view all contacts', 'edit groups')); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(2, $total); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); - $this->assertEquals('not-me-active', $groups[4]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(2, $groups['recordsTotal']); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); + $this->assertEquals('not-me-active', $groups['data'][4]['group_name']); } /** @@ -119,10 +121,11 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListViewAllContactsFoundTitle() { $this->_params['title'] = 'p'; $this->setPermissionAndRequest(array('view all contacts', 'edit groups')); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(2, $total); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); - $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(2, $groups['recordsTotal']); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['group_name']); } /** @@ -131,8 +134,9 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListViewAllContactsNotFoundTitle() { $this->_params['title'] = 'z'; $this->setPermissionAndRequest('view all contacts'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(0, $total); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(0, $groups['recordsTotal']); } /** @@ -140,10 +144,11 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { */ public function testGroupListEditAllContacts() { $this->setPermissionAndRequest(array('edit all contacts', 'edit groups')); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(2, $total); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); - $this->assertEquals('not-me-active', $groups[4]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(2, $groups['recordsTotal']); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); + $this->assertEquals('not-me-active', $groups['data'][4]['group_name']); } /** @@ -152,10 +157,11 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListViewAllContactsEnabled() { $this->_params['status'] = 1; $this->setPermissionAndRequest(array('view all contacts', 'edit groups')); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(2, $total); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); - $this->assertEquals('not-me-active', $groups[4]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(2, $groups['recordsTotal']); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); + $this->assertEquals('not-me-active', $groups['data'][4]['group_name']); } /** @@ -164,10 +170,11 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListViewAllContactsDisabled() { $this->_params['status'] = 2; $this->setPermissionAndRequest(array('view all contacts', 'edit groups')); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(2, $total); - $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); - $this->assertEquals('not-me-disabled', $groups[3]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(2, $groups['recordsTotal']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['group_name']); + $this->assertEquals('not-me-disabled', $groups['data'][3]['group_name']); } /** @@ -177,9 +184,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->_params['status'] = 2; $this->_params['title'] = 'n'; $this->setPermissionAndRequest(array('view all contacts', 'edit groups')); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(1, $total); - $this->assertEquals('not-me-disabled', $groups[3]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(1, $groups['recordsTotal']); + $this->assertEquals('not-me-disabled', $groups['data'][3]['group_name']); } /** @@ -189,9 +197,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->_params['status'] = 2; $this->_params['title'] = 'p'; $this->setPermissionAndRequest(array('view all contacts', 'edit groups')); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(1, $total); - $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(1, $groups['recordsTotal']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['group_name']); } /** @@ -200,12 +209,13 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListViewAllContactsAll() { $this->_params['status'] = 3; $this->setPermissionAndRequest(array('view all contacts', 'edit groups')); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(4, $total); - $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); - $this->assertEquals('not-me-disabled', $groups[3]['group_name']); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); - $this->assertEquals('not-me-active', $groups[4]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(4, $groups['recordsTotal']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['group_name']); + $this->assertEquals('not-me-disabled', $groups['data'][3]['group_name']); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); + $this->assertEquals('not-me-active', $groups['data'][4]['group_name']); } @@ -216,9 +226,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->setPermissionAndRequest('access CiviCRM'); $permissionClause = CRM_Contact_BAO_Group::getPermissionClause(TRUE); $this->assertEquals('1 = 0', $permissionClause); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(0, count($groups)); - $this->assertEquals(0, $total, 'Total returned should be accurate based on permissions'); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(0, $groups['data']); + $this->assertEquals(0, $groups['recordsTotal'], 'Total returned should be accurate based on permissions'); } /** @@ -227,9 +238,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListAccessCiviCRMEnabled() { $this->_params['status'] = 1; $this->setPermissionAndRequest('access CiviCRM'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(0, count($groups)); - $this->assertEquals(0, $total, 'Total returned should be accurate based on permissions'); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(0, $groups['data']); + $this->assertEquals(0, $groups['recordsTotal'], 'Total returned should be accurate based on permissions'); } /** @@ -238,9 +250,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListAccessCiviCRMDisabled() { $this->_params['status'] = 2; $this->setPermissionAndRequest('access CiviCRM'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(0, count($groups)); - $this->assertEquals(0, $total, 'Total returned should be accurate based on permissions'); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(0, $groups['data']); + $this->assertEquals(0, $groups['recordsTotal'], 'Total returned should be accurate based on permissions'); } /** @@ -249,9 +262,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListAccessCiviCRMAll() { $this->_params['status'] = 2; $this->setPermissionAndRequest('access CiviCRM'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(0, count($groups)); - $this->assertEquals(0, $total, 'Total returned should be accurate based on permissions'); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(0, $groups['data']); + $this->assertEquals(0, $groups['recordsTotal'], 'Total returned should be accurate based on permissions'); } /** @@ -260,9 +274,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListAccessCiviCRMFound() { $this->_params['title'] = 'p'; $this->setPermissionAndRequest('access CiviCRM'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(0, count($groups)); - $this->assertEquals(0, $total, 'Total returned should be accurate based on permissions'); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(0, $groups['data']); + $this->assertEquals(0, $groups['recordsTotal'], 'Total returned should be accurate based on permissions'); } /** @@ -271,48 +286,52 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListAccessCiviCRMNotFound() { $this->_params['title'] = 'z'; $this->setPermissionAndRequest('access CiviCRM'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(0, count($groups)); - $this->assertEquals(0, $total, 'Total returned should be accurate based on permissions'); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(0, $groups['data']); + $this->assertEquals(0, $groups['recordsTotal'], 'Total returned should be accurate based on permissions'); } public function testTraditionalACL() { $this->setupACL(); $this->setPermissionAndRequest('edit groups'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(1, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(1, $total, 'Total needs to be set correctly'); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(1, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(1, $groups['recordsTotal'], 'Total needs to be set correctly'); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); } public function testTraditionalACLNotFoundTitle() { $this->_params['title'] = 'n'; $this->setupACL(); - $this->setPermissionAndRequest('edit groups'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(0, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(0, $total, 'Total needs to be set correctly'); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(0, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(0, $groups['recordsTotal'], 'Total needs to be set correctly'); } public function testTraditionalACLFoundTitle() { $this->_params['title'] = 'p'; $this->setupACL(); $this->setPermissionAndRequest('edit groups'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(2, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(2, $total, 'Total needs to be set correctly'); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); - $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(2, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(2, $groups['recordsTotal'], 'Total needs to be set correctly'); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['group_name']); } public function testTraditionalACLDisabled() { $this->_params['status'] = 2; $this->setupACL(); $this->setPermissionAndRequest('edit groups'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(1, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(1, $total, 'Total needs to be set correctly'); - $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(1, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(1, $groups['recordsTotal'], 'Total needs to be set correctly'); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['group_name']); } public function testTraditionalACLDisabledFoundTitle() { @@ -320,41 +339,44 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->_params['title'] = 'p'; $this->setupACL(); $this->setPermissionAndRequest('edit groups'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(1, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(1, $total, 'Total needs to be set correctly'); - $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(1, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(1, $groups['recordsTotal'], 'Total needs to be set correctly'); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['group_name']); } public function testTraditionalACLDisabledNotFoundTitle() { $this->_params['status'] = 2; $this->_params['title'] = 'n'; $this->setupACL(); - $this->setPermissionAndRequest('edit groups'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(0, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(0, $total, 'Total needs to be set correctly'); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(0, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(0, $groups['recordsTotal'], 'Total needs to be set correctly'); } public function testTraditionalACLEnabled() { $this->_params['status'] = 1; $this->setupACL(); $this->setPermissionAndRequest('edit groups'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(1, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(1, $total, 'Total needs to be set correctly'); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(1, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(1, $groups['recordsTotal'], 'Total needs to be set correctly'); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); } public function testTraditionalACLAll() { $this->_params['status'] = 3; $this->setupACL(); $this->setPermissionAndRequest('edit groups'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(2, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(2, $total, 'Total needs to be set correctly'); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); - $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(2, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(2, $groups['recordsTotal'], 'Total needs to be set correctly'); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['group_name']); } /** @@ -363,10 +385,11 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListAclGroupHookDisabled() { $this->_params['status'] = 2; $this->setHookAndRequest(array('access CiviCRM', 'edit groups'), 'hook_civicrm_aclGroup'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(1, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(1, $total, 'Total needs to be set correctly'); - $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(1, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(1, $groups['recordsTotal'], 'Total needs to be set correctly'); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['group_name']); } /** @@ -376,10 +399,11 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->_params['status'] = 2; $this->_params['title'] = 'p'; $this->setHookAndRequest(array('access CiviCRM', 'edit groups'), 'hook_civicrm_aclGroup'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(1, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(1, $total, 'Total needs to be set correctly'); - $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(1, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(1, $groups['recordsTotal'], 'Total needs to be set correctly'); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['group_name']); } /** @@ -389,9 +413,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->_params['status'] = 2; $this->_params['title'] = 'n'; $this->setHookAndRequest('access CiviCRM', 'hook_civicrm_aclGroup'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(0, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(0, $total, 'Total needs to be set correctly'); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(0, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(0, $groups['recordsTotal'], 'Total needs to be set correctly'); } @@ -400,10 +425,11 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { */ public function testGroupListAclGroupHook() { $this->setHookAndRequest(array('access CiviCRM', 'edit groups'), 'hook_civicrm_aclGroup'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(1, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(1, $total, 'Total needs to be set correctly'); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(1, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(1, $groups['recordsTotal'], 'Total needs to be set correctly'); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); } /** @@ -412,9 +438,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListAclGroupHookTitleNotFound() { $this->_params['title'] = 'n'; $this->setHookAndRequest('access CiviCRM', 'hook_civicrm_aclGroup'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(0, $total, 'Total needs to be set correctly'); - $this->assertEquals(0, count($groups), 'Returned groups should exclude disabled by default'); + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $params = $this->_params; + $this->assertEquals(0, $groups['recordsTotal'], 'Total needs to be set correctly'); + $this->assertEquals(0, $groups['data'], 'Returned groups should exclude disabled by default'); } /** @@ -423,11 +450,11 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListAclGroupHookTitleFound() { $this->_params['title'] = 'p'; $this->setHookAndRequest(array('access CiviCRM', 'edit groups'), 'hook_civicrm_aclGroup'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(2, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(2, $total, 'Total needs to be set correctly'); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); - $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(2, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(2, $groups['recordsTotal'], 'Total needs to be set correctly'); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['group_name']); } /** @@ -436,11 +463,12 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListAclGroupHookAll() { $this->_params['status'] = 3; $this->setHookAndRequest(array('access CiviCRM', 'edit groups'), 'hook_civicrm_aclGroup'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(2, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(2, $total, 'Total needs to be set correctly'); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); - $this->assertEquals('pick-me-disabled', $groups[1]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(2, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(2, $groups['recordsTotal'], 'Total needs to be set correctly'); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['group_name']); } /** @@ -449,10 +477,11 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListAclGroupHookEnabled() { $this->_params['status'] = 1; $this->setHookAndRequest(array('access CiviCRM', 'edit groups'), 'hook_civicrm_aclGroup'); - list($groups, $total) = CRM_Group_Page_AJAX::getGroupList(); - $this->assertEquals(1, count($groups), 'Returned groups should exclude disabled by default'); - $this->assertEquals(1, $total, 'Total needs to be set correctly'); - $this->assertEquals('pick-me-active', $groups[2]['group_name']); + $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(1, $groups['data'], 'Returned groups should exclude disabled by default'); + $this->assertEquals(1, $groups['recordsTotal'], 'Total needs to be set correctly'); + $this->assertEquals('pick-me-active', $groups['data'][2]['group_name']); } /** -- 2.25.1