From 5bf58d02d6878c40b347093f96310096665395e3 Mon Sep 17 00:00:00 2001 From: Joseph Lacey Date: Wed, 17 Feb 2016 13:11:07 -0500 Subject: [PATCH] Fixes to Group Page PHPUnit test --- CRM/Group/Page/AJAX.php | 8 +------- tests/phpunit/CRM/Group/Page/AjaxTest.php | 9 +++++---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/CRM/Group/Page/AJAX.php b/CRM/Group/Page/AJAX.php index 57d57b0318..b492427a1c 100644 --- a/CRM/Group/Page/AJAX.php +++ b/CRM/Group/Page/AJAX.php @@ -57,7 +57,7 @@ class CRM_Group_Page_AJAX { $columns = CRM_Utils_Array::value('columns', $params, array()); foreach ($columns as $key => $value) { $sortMapper[$key] = $value['data']; - }; + } $offset = isset($_GET['start']) ? CRM_Utils_Type::escape($_GET['start'], 'Integer') : 0; $rowCount = isset($_GET['length']) ? CRM_Utils_Type::escape($_GET['length'], 'Integer') : 25; @@ -86,12 +86,6 @@ class CRM_Group_Page_AJAX { } } - //add setting so this can be tested by unit test - //@todo - ideally the portion of this that retrieves the groups should be extracted into a function separate - // from the one which deals with web inputs & outputs so we have a properly testable & re-usable function - if (!empty($params['is_unit_test'])) { - return array($groups['data'], $params['total']); - } CRM_Utils_JSON::output($groups); } } diff --git a/tests/phpunit/CRM/Group/Page/AjaxTest.php b/tests/phpunit/CRM/Group/Page/AjaxTest.php index d27085ddb2..cbea43d9d1 100644 --- a/tests/phpunit/CRM/Group/Page/AjaxTest.php +++ b/tests/phpunit/CRM/Group/Page/AjaxTest.php @@ -86,10 +86,11 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase { */ public function testGroupListViewAllContacts() { $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']); } /** -- 2.25.1