*
* (PHP 5)
*
- * @author Walt Haas <walt@dharmatech.org> (801) 534-1262
- * @copyright Copyright CiviCRM LLC (C) 2009
- * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html
+ * @author Walt Haas <walt@dharmatech.org> (801) 534-1262
+ * @copyright Copyright CiviCRM LLC (C) 2009
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html
* GNU Affero General Public License version 3
- * @version $Id: ActivityTest.php 31254 2010-12-15 10:09:29Z eileen $
- * @package CiviCRM
+ * @version $Id: ActivityTest.php 31254 2010-12-15 10:09:29Z eileen $
+ * @package CiviCRM
*
* This file is part of CiviCRM
*
/**
* Test APIv3 civicrm_case_* functions
*
- * @package CiviCRM_APIv3
+ * @package CiviCRM_APIv3
*/
class api_v3_CaseTest extends CiviCaseTestCase {
protected $_params;
protected $_entity;
- protected $_apiversion =3;
+ protected $_apiversion = 3;
protected $followup_activity_type_value;
/**
}
/**
- * check with empty array
+ * Check with empty array
*/
- function testCaseCreateEmpty() {
+ public function testCaseCreateEmpty() {
$result = $this->callAPIFailure('case', 'create', array());
}
/**
- * check if required fields are not passed
+ * Check if required fields are not passed
*/
- function testCaseCreateWithoutRequired() {
+ public function testCaseCreateWithoutRequired() {
$params = array(
'subject' => 'this case should fail',
'case_type_id' => 1,
/**
* Test create function with valid parameters
*/
- function testCaseCreate() {
+ public function testCaseCreate() {
// Create Case
$params = $this->_params;
// Test using label instead of value
unset($params['case_type_id']);
- $params['case_type'] = 'Housing Support';
- $result = $this->callAPISuccess('case', 'create', $params);
+ $params['case_type'] = $this->caseType;
+ $result = $this->callAPIAndDocument('case', 'create', $params, __FUNCTION__, __FILE__);
$id = $result['id'];
// Check result
/**
* Test update (create with id) function with valid parameters
*/
- function testCaseUpdate() {
+ public function testCaseUpdate() {
// Create Case
$params = $this->_params;
// Test using name instead of value
unset($params['case_type_id']);
- $params['case_type'] = 'Housing Support';
+ $params['case_type'] = $this->caseType;
$result = $this->callAPISuccess('case', 'create', $params);
$id = $result['id'];
$result = $this->callAPISuccess('case', 'get', array('id' => $id));
/**
* Test delete function with valid parameters
*/
- function testCaseDelete() {
+ public function testCaseDelete() {
// Create Case
$result = $this->callAPISuccess('case', 'create', $this->_params);
/**
* Test get function based on activity
*/
- function testCaseGetByActivity() {
+ public function testCaseGetByActivity() {
// Create Case
$result = $this->callAPISuccess('case', 'create', $this->_params);
$id = $result['id'];
$activity = $case['activities'][0];
// Fetch case based on an activity id
- $result = $this->callAPISuccess('case', 'get', array('activity_id' => $activity, 'return' => 'activities,contacts'));
+ $result = $this->callAPISuccess('case', 'get', array(
+ 'activity_id' => $activity,
+ 'return' => 'activities,contacts'
+ ));
$this->assertEquals(FALSE, empty($result['values'][$id]), 'in line ' . __LINE__);
$this->assertEquals($result['values'][$id], $case, 'in line ' . __LINE__);
}
/**
* Test get function based on contact id
*/
- function testCaseGetByContact() {
+ public function testCaseGetByContact() {
// Create Case
$result = $this->callAPISuccess('case', 'create', $this->_params);
$id = $result['id'];
$case = $this->callAPISuccess('case', 'getsingle', array('id' => $id));
// Fetch case based on client contact id
- $result = $this->callAPISuccess('case', 'get', array('client_id' => $this->_params['contact_id'], 'return' => array('activities', 'contacts')));
+ $result = $this->callAPISuccess('case', 'get', array(
+ 'client_id' => $this->_params['contact_id'],
+ 'return' => array('activities', 'contacts')
+ ));
$this->assertAPIArrayComparison($result['values'][$id], $case);
}
/**
* Test get function based on subject
*/
- function testCaseGetBySubject() {
+ public function testCaseGetBySubject() {
// Create Case
$result = $this->callAPISuccess('case', 'create', $this->_params);
$id = $result['id'];
$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')));
+ $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() {
+ public 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')));
+ $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() {
+ public function testCaseGetNoCriteria() {
// Create Case
$result = $this->callAPISuccess('case', 'create', $this->_params);
$id = $result['id'];
/**
* Test activity api create for case activities
*/
- function testCaseActivityCreate() {
+ public function testCaseActivityCreate() {
// Create a case first
$params = $this->_params;
$result = $this->callAPISuccess('case', 'create', $params);
/**
* Test activity api update for case activities
*/
- function testCaseActivityUpdate() {
+ public function testCaseActivityUpdate() {
// Need to create the case and activity before we can update it
$this->testCaseActivityCreate();
//TODO: check some more things
}
- function testCaseActivityUpdateCustom() {
+ public function testCaseActivityUpdateCustom() {
// Create a case first
$result = $this->callAPISuccess('case', 'create', $this->_params);