Update Unit test styling to cover the future coder version
[civicrm-core.git] / tests / phpunit / api / v3 / CaseContactTest.php
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;
12 protected $_cid2;
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();
32 $this->_cid2 = $this->individualCreate(array(), 1);
33
34 $this->_case = $this->callAPISuccess('case', 'create', array(
35 'case_type_id' => $this->caseTypeId,
36 'subject' => __CLASS__,
37 'contact_id' => $this->_cid,
38 ));
39
40 $this->_params = array(
41 'case_id' => $this->_case['id'],
42 'contact_id' => $this->_cid2,
43 );
44 }
45
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']);
51 }
52
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
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']);
65 }
66
67 }