From: Joseph Lacey Date: Mon, 28 Mar 2016 20:57:13 +0000 (-0400) Subject: Further fixes to Group Page PHPUnit test, deals with new returned structure and... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=00fb62abc823b3df997ff3e7421b041ca7c089b3;p=civicrm-core.git Further fixes to Group Page PHPUnit test, deals with new returned structure and few other bugs. --- diff --git a/tests/phpunit/CRM/Group/Page/AjaxTest.php b/tests/phpunit/CRM/Group/Page/AjaxTest.php index c5069e9f7e..e4b5ed492d 100644 --- a/tests/phpunit/CRM/Group/Page/AjaxTest.php +++ b/tests/phpunit/CRM/Group/Page/AjaxTest.php @@ -89,28 +89,30 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $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']); + $this->assertEquals('not-me-active', $groups['data'][0]['title']); + $this->assertEquals('pick-me-active', $groups['data'][1]['title']); } /** * Check Group Edit w/o 'edit groups' permission. + * + * FIXME permissions to edit groups can only be determined by the links, which is ridiculously long */ public function testGroupEditWithAndWithoutPermission() { $this->setPermissionAndRequest('view all contacts'); $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']); + $this->assertEquals('Contacts', $groups['data'][0]['links']); + $this->assertEquals('Contacts', $groups['data'][1]['links']); // as per changes made in PR-6822 $this->setPermissionAndRequest(array('view all contacts', 'edit groups')); $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']); + $this->assertEquals('ContactsSettingsmore', $groups['data'][0]['links']); + $this->assertEquals('ContactsSettingsmore', $groups['data'][1]['links']); } /** @@ -124,8 +126,8 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $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']); + $this->assertEquals('pick-me-active', $groups['data'][0]['title']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['title']); } /** @@ -147,8 +149,8 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $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']); + $this->assertEquals('not-me-active', $groups['data'][0]['title']); + $this->assertEquals('pick-me-active', $groups['data'][1]['title']); } /** @@ -160,8 +162,8 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $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']); + $this->assertEquals('not-me-active', $groups['data'][0]['title']); + $this->assertEquals('pick-me-active', $groups['data'][1]['title']); } /** @@ -173,8 +175,8 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $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']); + $this->assertEquals('not-me-disabled', $groups['data'][0]['title']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['title']); } /** @@ -187,7 +189,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $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']); + $this->assertEquals('not-me-disabled', $groups['data'][0]['title']); } /** @@ -200,7 +202,7 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $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']); + $this->assertEquals('pick-me-disabled', $groups['data'][0]['title']); } /** @@ -212,10 +214,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $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']); + $this->assertEquals('not-me-active', $groups['data'][0]['title']); + $this->assertEquals('not-me-disabled', $groups['data'][1]['title']); + $this->assertEquals('pick-me-active', $groups['data'][2]['title']); + $this->assertEquals('pick-me-disabled', $groups['data'][3]['title']); } @@ -297,9 +299,9 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->setPermissionAndRequest('edit groups'); $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, count($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']); + $this->assertEquals('pick-me-active', $groups['data'][0]['title']); } public function testTraditionalACLNotFoundTitle() { @@ -317,10 +319,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->setPermissionAndRequest('edit groups'); $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, count($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']); + $this->assertEquals('pick-me-active', $groups['data'][0]['title']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['title']); } public function testTraditionalACLDisabled() { @@ -329,9 +331,9 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->setPermissionAndRequest('edit groups'); $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, count($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']); + $this->assertEquals('pick-me-disabled', $groups['data'][0]['title']); } public function testTraditionalACLDisabledFoundTitle() { @@ -341,9 +343,9 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->setPermissionAndRequest('edit groups'); $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, count($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']); + $this->assertEquals('pick-me-disabled', $groups['data'][0]['title']); } public function testTraditionalACLDisabledNotFoundTitle() { @@ -362,9 +364,9 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->setPermissionAndRequest('edit groups'); $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, count($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']); + $this->assertEquals('pick-me-active', $groups['data'][0]['title']); } public function testTraditionalACLAll() { @@ -373,10 +375,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->setPermissionAndRequest('edit groups'); $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, count($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']); + $this->assertEquals('pick-me-active', $groups['data'][0]['title']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['title']); } /** @@ -387,9 +389,9 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->setHookAndRequest(array('access CiviCRM', 'edit groups'), 'hook_civicrm_aclGroup'); $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, count($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']); + $this->assertEquals('pick-me-disabled', $groups['data'][0]['title']); } /** @@ -401,9 +403,9 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->setHookAndRequest(array('access CiviCRM', 'edit groups'), 'hook_civicrm_aclGroup'); $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, count($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']); + $this->assertEquals('pick-me-disabled', $groups['data'][0]['title']); } /** @@ -427,9 +429,9 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->setHookAndRequest(array('access CiviCRM', 'edit groups'), 'hook_civicrm_aclGroup'); $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, count($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']); + $this->assertEquals('pick-me-active', $groups['data'][0]['title']); } /** @@ -438,10 +440,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListAclGroupHookTitleNotFound() { $this->_params['title'] = 'n'; $this->setHookAndRequest('access CiviCRM', 'hook_civicrm_aclGroup'); - $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); $params = $this->_params; + $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); + $this->assertEquals(0, count($groups['data']), 'Returned groups should exclude disabled by default'); $this->assertEquals(0, $groups['recordsTotal'], 'Total needs to be set correctly'); - $this->assertEquals(0, $groups['data'], 'Returned groups should exclude disabled by default'); } /** @@ -450,11 +452,12 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { public function testGroupListAclGroupHookTitleFound() { $this->_params['title'] = 'p'; $this->setHookAndRequest(array('access CiviCRM', 'edit groups'), 'hook_civicrm_aclGroup'); + $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, count($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']); + $this->assertEquals('pick-me-active', $groups['data'][0]['title']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['title']); } /** @@ -465,10 +468,10 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->setHookAndRequest(array('access CiviCRM', 'edit groups'), 'hook_civicrm_aclGroup'); $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, count($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']); + $this->assertEquals('pick-me-active', $groups['data'][0]['title']); + $this->assertEquals('pick-me-disabled', $groups['data'][1]['title']); } /** @@ -479,9 +482,9 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { $this->setHookAndRequest(array('access CiviCRM', 'edit groups'), 'hook_civicrm_aclGroup'); $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, count($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']); + $this->assertEquals('pick-me-active', $groups['data'][0]['title']); } /**