/** * Helper function to create Custom Group * * @deprecated - use functions on test case parent class * * @param $group * @param null $extends * @param bool $isMultiple * * @return object of created group */ static function createGroup($group, $extends = NULL, $isMultiple = FALSE) { if (empty($group)) { if (isset($extends) && !is_array($extends)) { $extends = array($extends); } $group = array('title' => 'Test_Group', 'name' => 'test_group', 'extends' => $extends, 'style' => 'Inline', 'is_multiple' => $isMultiple, 'is_active' => 1, 'version' => 3); } else { // this is done for backward compatibility // with tests older than 3.2.3 if (isset($group['extends']) && !is_array($group['extends'])) { $group['extends'] = array($group['extends']); } } $result = civicrm_api('custom_group', 'create', $group); if ($result['is_error']) { return NULL; } // this is done for backward compatibility // with tests older than 3.2.3 require_once 'CRM/Core/BAO/CustomGroup.php'; $group = new CRM_Core_BAO_CustomGroup(); $group->id = $result['id']; $group->find(TRUE); return $group; }
/** * Test deleteGroup. */ public function testDeleteGroup() { $customGroupTitle = 'My Custom Group'; $groupParams = array('title' => $customGroupTitle, 'name' => 'my_custom_group', 'style' => 'Tab', 'extends' => 'Individual', 'is_active' => 1); $customGroup = $this->customGroupCreate($groupParams); $groupObject = new CRM_Core_BAO_CustomGroup(); $groupObject->id = $customGroup['id']; $groupObject->find(TRUE); $isDelete = CRM_Core_BAO_CustomGroup::deleteGroup($groupObject); // Check it worked! $this->assertEquals(TRUE, $isDelete); $this->assertDBNull('CRM_Core_DAO_CustomGroup', $customGroup['id'], 'title', 'id', 'Database check for custom group record.'); }