$value['class'] = array_diff($value['class'], array('crm-row-parent'));
}
$group['DT_RowId'] = 'row_' . $value['id'];
- if (!$params['parentsOnly']) {
+ if (empty($params['parentsOnly'])) {
foreach ($value['class'] as $id => $class) {
if ($class == 'crm-group-parent') {
unset($value['class'][$id]);
$params['page'] = 1;
$params['rp'] = 0;
$groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
-
- CRM_Utils_JSON::output($groups);
}
else {
$requiredParams = array();
$groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
}
}
+ }
- CRM_Utils_JSON::output($groups);
+ if (!empty($_GET['is_unit_test'])) {
+ return $groups;
}
+
+ CRM_Utils_JSON::output($groups);
}
}
$_REQUEST = $this->_params;
}
+ /**
+ * CRM-18528 - Retrieve groups with filter
+ */
+ public function testGroupListWithFilter() {
+ global $_GET;
+ $_GET = $this->_params;
+ $obj = new CRM_Group_Page_AJAX();
+
+ //filter with title
+ $_GET['title'] = "not-me-active";
+ $groups = $obj->getGroupList();
+ $this->assertEquals(1, $groups['recordsTotal']);
+ $this->assertEquals('not-me-active', $groups['data'][0]['title']);
+ unset($_GET['title']);
+
+ // check on status
+ $_GET['status'] = 2;
+ $groups = $obj->getGroupList();
+ $this->assertEquals(2, $groups['recordsTotal']);
+ $this->assertEquals('not-me-disabled', $groups['data'][0]['title']);
+ $this->assertEquals('pick-me-disabled', $groups['data'][1]['title']);
+ }
+
/**
* Retrieve groups as 'view all contacts'
*/