protected $followup_activity_type_value;
protected $caseTypeId;
protected $caseStatusGroup;
- protected $caseTypeGroup;
protected $optionValues;
- public $_eNoticeCompliant = TRUE;
+
/**
* Test setup for every test
*
'name' => 'case_status',
'format.only_id' => 1)
);
- $this->caseTypeGroup = $this->callAPISuccess('option_group', 'get', array(
- 'name' => 'case_type',
- 'format.only_id' => 1)
- );
- $caseTypes = $this->callAPISuccess('option_value', 'Create', array(
- 'option_group_id' => $this->caseTypeGroup,
- 'name' => 'housing_support',
- 'label' => "Housing Support",
- 'sequential' => 1,
- 'description' => 'Help homeless individuals obtain temporary and long-term housing',
- ));
-
- $this->caseTypeId = $caseTypes['values'][0]['value'];
- $this->optionValues[] = $caseTypes['id'];
$optionValues = array(
'Medical evaluation' => 'Medical evaluation',
'Mental health evaluation' => "Mental health evaluation",
// store for cleanup
$this->optionValues[] = $activityTypes['id'];
}
- $tablesToTruncate = array(
+ $this->caseTypeId = 1;
+ $this->tablesToTruncate = array(
'civicrm_activity',
'civicrm_contact',
'civicrm_custom_group',
'civicrm_case',
'civicrm_case_contact',
'civicrm_case_activity',
+ 'civicrm_case_type',
'civicrm_activity_contact',
'civicrm_relationship',
'civicrm_relationship_type',
);
- $this->quickCleanup($tablesToTruncate);
+ $this->quickCleanup($this->tablesToTruncate);
+
+ $this->loadAllFixtures();
$activityTypes = $this->callAPISuccess('option_value', 'get', array(
'option_group_id' => 2,
'sequential' => 1,
));
$this->followup_activity_type_value = $activityTypes['values'][0]['value'];
- // Insert a row in civicrm_contact creating contact 17
- $op = new PHPUnit_Extensions_Database_Operation_Insert();
- $op->execute($this->_dbconn,
- new PHPUnit_Extensions_Database_DataSet_XMLDataSet(
- dirname(__FILE__) . '/dataset/contact_17.xml'
- )
- );
-
- //Create relationship types
- $relTypeParams = array(
- 'name_a_b' => 'Case Coordinator is',
- 'label_a_b' => 'Case Coordinator is',
- 'name_b_a' => 'Case Coordinator',
- 'label_b_a' => 'Case Coordinator',
- 'description' => 'Case Coordinator',
- 'contact_type_a' => 'Individual',
- 'contact_type_b' => 'Individual',
- 'is_reserved' => 0,
- 'is_active' => 1,
- );
- $this->relationshipTypeCreate($relTypeParams);
-
- $relTypeParams = array(
- 'name_a_b' => 'Homeless Services Coordinator is',
- 'label_a_b' => 'Homeless Services Coordinator is',
- 'name_b_a' => 'Homeless Services Coordinator',
- 'label_b_a' => 'Homeless Services Coordinator',
- 'description' => 'Homeless Services Coordinator',
- 'contact_type_a' => 'Individual',
- 'contact_type_b' => 'Individual',
- 'is_reserved' => 0,
- 'is_active' => 1,
- );
- $this->relationshipTypeCreate($relTypeParams);
-
- $relTypeParams = array(
- 'name_a_b' => 'Health Services Coordinator is',
- 'label_a_b' => 'Health Services Coordinator is',
- 'name_b_a' => 'Health Services Coordinator',
- 'label_b_a' => 'Health Services Coordinator',
- 'description' => 'Health Services Coordinator',
- 'contact_type_a' => 'Individual',
- 'contact_type_b' => 'Individual',
- 'is_reserved' => 0,
- 'is_active' => 1,
- );
- $this->relationshipTypeCreate($relTypeParams);
-
- $relTypeParams = array(
- 'name_a_b' => 'Senior Services Coordinator is',
- 'label_a_b' => 'Senior Services Coordinator is',
- 'name_b_a' => 'Senior Services Coordinator',
- 'label_b_a' => 'Senior Services Coordinator',
- 'description' => 'Senior Services Coordinator',
- 'contact_type_a' => 'Individual',
- 'contact_type_b' => 'Individual',
- 'is_reserved' => 0,
- 'is_active' => 1,
- );
- $this->relationshipTypeCreate($relTypeParams);
-
- $relTypeParams = array(
- 'name_a_b' => 'Benefits Specialist is',
- 'label_a_b' => 'Benefits Specialist is',
- 'name_b_a' => 'Benefits Specialist',
- 'label_b_a' => 'Benefits Specialist',
- 'description' => 'Benefits Specialist',
- 'contact_type_a' => 'Individual',
- 'contact_type_b' => 'Individual',
- 'is_reserved' => 0,
- 'is_active' => 1,
- );
- $this->relationshipTypeCreate($relTypeParams);
// enable the default custom templates for the case type xml files
$this->customDirectories(array('template_path' => TRUE));
* @access protected
*/
function tearDown() {
- foreach ($this->optionValues as $id) {
- $this->callAPISuccess('option_value', 'delete', array('id' => $id));
- }
- $tablesToTruncate = array(
- 'civicrm_contact',
- 'civicrm_activity',
- 'civicrm_case',
- 'civicrm_case_contact',
- 'civicrm_case_activity',
- 'civicrm_activity_contact',
- 'civicrm_relationship',
- 'civicrm_relationship_type',
- );
- $this->quickCleanup($tablesToTruncate, TRUE);
+ $this->quickCleanup($this->tablesToTruncate, TRUE);
$this->customDirectories(array('template_path' => FALSE));
}
// Check result
$result = $this->callAPISuccess('case', 'get', array('id' => $id));
- $this->assertEquals($result['values'][$id]['id'], 1, 'in line ' . __LINE__);
+ $this->assertEquals($result['values'][$id]['id'], $id, 'in line ' . __LINE__);
$this->assertEquals($result['values'][$id]['case_type_id'], $this->caseTypeId, 'in line ' . __LINE__);
$this->assertEquals($result['values'][$id]['subject'], $params['subject'], 'in line ' . __LINE__);
}
// Create Case
$params = $this->_params;
// Test using name instead of value
- $params['case_type_id'] = 'housing_support';
+ unset($params['case_type_id']);
+ $params['case_type'] = 'Housing Support';
$result = $this->callAPISuccess('case', 'create', $params);
$id = $result['id'];
$result = $this->callAPISuccess('case', 'get', array('id' => $id));
$this->assertAPIArrayComparison($result['values'][$id], $case);
}
+ /**
+ * Test get function based on subject
+ */
+ function testCaseGetBySubject() {
+ // Create Case
+ $result = $this->callAPISuccess('case', 'create', $this->_params);
+ $id = $result['id'];
+
+ // Store result for later
+ $case = $this->callAPISuccess('case', 'getsingle', array('id' => $id));
+
+ // Fetch case based on client contact id
+ $result = $this->callAPISuccess('case', 'get', array('subject' => $this->_params['subject'], 'return' => array('activities', 'contacts')));
+ $this->assertAPIArrayComparison($result['values'][$id], $case);
+ }
+
+ /**
+ * Test get function based on wrong subject
+ */
+ function testCaseGetByWrongSubject() {
+ // Create Case
+ $result = $this->callAPISuccess('case', 'create', $this->_params);
+ $id = $result['id'];
+
+ // Append 'wrong' to subject so that it is no longer the same
+ $result = $this->callAPISuccess('case', 'get', array('subject' => $this->_params['subject'] . 'wrong', 'return' => array('activities', 'contacts')));
+ $this->assertEquals(0, $result['count'], 'in line ' . __LINE__);
+ }
+
+ /**
+ * Test get function with no criteria
+ */
+ function testCaseGetNoCriteria() {
+ // Create Case
+ $result = $this->callAPISuccess('case', 'create', $this->_params);
+ $id = $result['id'];
+
+ // Store result for later
+ $case = $this->callAPISuccess('case', 'getsingle', array('id' => $id));
+
+ $result = $this->callAPISuccess('case', 'get', array('return' => array('activities', 'contacts')));
+ $this->assertAPIArrayComparison($result['values'][$id], $case);
+ }
+
/**
* Test activity api create for case activities
*/