From: Coleman Watts Date: Fri, 1 Jan 2016 23:02:36 +0000 (-0500) Subject: Case api test fixes X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e61d8c45745c10d8d7a2eacfd74b6f7e888e2a4e;p=civicrm-core.git Case api test fixes --- diff --git a/api/v3/Case.php b/api/v3/Case.php index 205a6068df..cb57f1537a 100644 --- a/api/v3/Case.php +++ b/api/v3/Case.php @@ -252,7 +252,7 @@ function civicrm_api3_case_get($params) { // For historic reasons we return these by default only when fetching a case by id if (!empty($params['id']) && empty($options['return'])) { - $options['return'] += array('contacts' => 1, 'activities' => 1, 'contact_id' => 1); + $options['return'] = array('contacts' => 1, 'activities' => 1, 'contact_id' => 1); } foreach ($foundcases['values'] as &$case) { diff --git a/tests/phpunit/api/v3/CaseTest.php b/tests/phpunit/api/v3/CaseTest.php index 6e929935b6..d4112f19ea 100644 --- a/tests/phpunit/api/v3/CaseTest.php +++ b/tests/phpunit/api/v3/CaseTest.php @@ -124,17 +124,16 @@ class api_v3_CaseTest extends CiviCaseTestCase { $params['case_type'] = $this->caseType; $result = $this->callAPISuccess('case', 'create', $params); $id = $result['id']; - $result = $this->callAPISuccess('case', 'get', array('id' => $id)); - $case = $result['values'][$id]; + $case = $this->callAPISuccess('case', 'getsingle', array('id' => $id)); // Update Case. $params = array('id' => $id); - $params['subject'] = $case['subject'] = 'Something Else'; + $params['subject'] = $case['subject'] = $case['case_subject'] = 'Something Else'; $this->callAPISuccess('case', 'create', $params); // Verify that updated case is exactly equal to the original with new subject. - $result = $this->callAPISuccess('case', 'get', array('case_id' => $id)); - $this->assertEquals($result['values'][$id], $case); + $result = $this->callAPISuccess('case', 'getsingle', array('case_id' => $id)); + $this->assertAPIArrayComparison($result, $case); } /** @@ -169,14 +168,14 @@ class api_v3_CaseTest extends CiviCaseTestCase { $id = $result['id']; // Check result - we should get a list of activity ids - $result = $this->callAPISuccess('case', 'get', array('id' => $id)); + $result = $this->callAPISuccess('case', 'get', array('id' => $id, 'return' => 'activities')); $case = $result['values'][$id]; $activity = $case['activities'][0]; // Fetch case based on an activity id $result = $this->callAPISuccess('case', 'get', array( 'activity_id' => $activity, - 'return' => 'activities,contacts', + 'return' => 'activities', )); $this->assertEquals(FALSE, empty($result['values'][$id])); $this->assertEquals($result['values'][$id], $case); @@ -191,7 +190,7 @@ class api_v3_CaseTest extends CiviCaseTestCase { $id = $result['id']; // Store result for later - $case = $this->callAPISuccess('case', 'getsingle', array('id' => $id)); + $case = $this->callAPISuccess('case', 'getsingle', array('id' => $id, 'return' => array('activities', 'contacts'))); // Fetch case based on client contact id $result = $this->callAPISuccess('case', 'get', array( @@ -210,12 +209,12 @@ class api_v3_CaseTest extends CiviCaseTestCase { $id = $result['id']; // Store result for later - $case = $this->callAPISuccess('case', 'getsingle', array('id' => $id)); + $case = $this->callAPISuccess('case', 'getsingle', array('id' => $id, 'return' => 'subject')); // Fetch case based on client contact id $result = $this->callAPISuccess('case', 'get', array( 'subject' => $this->_params['subject'], - 'return' => array('activities', 'contacts'), + 'return' => array('subject'), )); $this->assertAPIArrayComparison($result['values'][$id], $case); } @@ -242,9 +241,9 @@ class api_v3_CaseTest extends CiviCaseTestCase { $id = $result['id']; // Store result for later - $case = $this->callAPISuccess('case', 'getsingle', array('id' => $id)); + $case = $this->callAPISuccess('case', 'getsingle', array('id' => $id, 'return' => 'contact_id')); - $result = $this->callAPISuccess('case', 'get', array('return' => array('activities', 'contacts'))); + $result = $this->callAPISuccess('case', 'get', array('limit' => 0, 'return' => array('contact_id'))); $this->assertAPIArrayComparison($result['values'][$id], $case); }