Commit | Line | Data |
---|---|---|
f826e3eb CW |
1 | <?php |
2 | /** | |
3 | * Test APIv3 civicrm_case_* functions | |
4 | * | |
5 | * @package CiviCRM_APIv3 | |
6 | * @group headless | |
7 | */ | |
8 | class api_v3_CaseContactTest extends CiviCaseTestCase { | |
9 | protected $_params; | |
10 | protected $_entity; | |
11 | protected $_cid; | |
be84446f | 12 | protected $_cid2; |
f826e3eb CW |
13 | /** |
14 | * Activity ID of created case. | |
15 | * | |
16 | * @var int | |
17 | */ | |
18 | protected $_caseActivityId; | |
19 | ||
20 | /** | |
21 | * Test setup for every test. | |
22 | * | |
23 | * Connect to the database, truncate the tables that will be used | |
24 | * and redirect stdin to a temporary file. | |
25 | */ | |
26 | public function setUp() { | |
27 | $this->_entity = 'case'; | |
28 | ||
29 | parent::setUp(); | |
30 | ||
31 | $this->_cid = $this->individualCreate(); | |
9099cab3 | 32 | $this->_cid2 = $this->individualCreate([], 1); |
f826e3eb | 33 | |
9099cab3 | 34 | $this->_case = $this->callAPISuccess('case', 'create', [ |
f826e3eb CW |
35 | 'case_type_id' => $this->caseTypeId, |
36 | 'subject' => __CLASS__, | |
37 | 'contact_id' => $this->_cid, | |
9099cab3 | 38 | ]); |
be84446f | 39 | |
9099cab3 | 40 | $this->_params = [ |
be84446f MW |
41 | 'case_id' => $this->_case['id'], |
42 | 'contact_id' => $this->_cid2, | |
9099cab3 | 43 | ]; |
f826e3eb CW |
44 | } |
45 | ||
46 | public function testCaseContactGet() { | |
9099cab3 | 47 | $result = $this->callAPIAndDocument('CaseContact', 'get', [ |
f826e3eb | 48 | 'contact_id' => $this->_cid, |
9099cab3 | 49 | ], __FUNCTION__, __FILE__); |
f826e3eb CW |
50 | $this->assertEquals($this->_case['id'], $result['id']); |
51 | } | |
52 | ||
be84446f MW |
53 | /** |
54 | * Test create function with valid parameters. | |
55 | */ | |
56 | public function testCaseContactCreate() { | |
57 | $params = $this->_params; | |
58 | $result = $this->callAPIAndDocument('CaseContact', 'create', $params, __FUNCTION__, __FILE__); | |
59 | $id = $result['id']; | |
60 | ||
61 | // Check result | |
9099cab3 | 62 | $result = $this->callAPISuccess('CaseContact', 'get', ['id' => $id]); |
be84446f MW |
63 | $this->assertEquals($result['values'][$id]['case_id'], $params['case_id']); |
64 | $this->assertEquals($result['values'][$id]['contact_id'], $params['contact_id']); | |
65 | } | |
66 | ||
f826e3eb | 67 | } |