3 * Test APIv3 civicrm_case_* functions
5 * @package CiviCRM_APIv3
8 class api_v3_CaseContactTest
extends CiviCaseTestCase
{
14 * Activity ID of created case.
18 protected $_caseActivityId;
21 * Test setup for every test.
23 * Connect to the database, truncate the tables that will be used
24 * and redirect stdin to a temporary file.
26 public function setUp() {
27 $this->_entity
= 'case';
31 $this->_cid
= $this->individualCreate();
32 $this->_cid2
= $this->individualCreate(array(), 1);
34 $this->_case
= $this->callAPISuccess('case', 'create', array(
35 'case_type_id' => $this->caseTypeId
,
36 'subject' => __CLASS__
,
37 'contact_id' => $this->_cid
,
40 $this->_params
= array(
41 'case_id' => $this->_case
['id'],
42 'contact_id' => $this->_cid2
,
46 public function testCaseContactGet() {
47 $result = $this->callAPIAndDocument('CaseContact', 'get', array(
48 'contact_id' => $this->_cid
,
49 ), __FUNCTION__
, __FILE__
);
50 $this->assertEquals($this->_case
['id'], $result['id']);
54 * Test create function with valid parameters.
56 public function testCaseContactCreate() {
57 $params = $this->_params
;
58 $result = $this->callAPIAndDocument('CaseContact', 'create', $params, __FUNCTION__
, __FILE__
);
62 $result = $this->callAPISuccess('CaseContact', 'get', array('id' => $id));
63 $this->assertEquals($result['values'][$id]['case_id'], $params['case_id']);
64 $this->assertEquals($result['values'][$id]['contact_id'], $params['contact_id']);