Commit | Line | Data |
---|---|---|
3ed73cde | 1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
3ed73cde | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
3ed73cde | 7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | ||
3ed73cde | 29 | /** |
30 | * Test APIv3 civicrm_activity_contact* functions | |
31 | * | |
6c6e6187 TO |
32 | * @package CiviCRM_APIv3 |
33 | * @subpackage API_Activity | |
acb109b7 | 34 | * @group headless |
3ed73cde | 35 | */ |
36 | class api_v3_ActivityContactTest extends CiviUnitTestCase { | |
37 | protected $_apiversion; | |
38 | protected $_contactID; | |
39 | protected $_activityID; | |
40 | protected $_params; | |
41 | ||
42 | ||
00be9182 | 43 | public function setUp() { |
3ed73cde | 44 | $this->_apiversion = 3; |
45 | parent::setUp(); | |
323df81e | 46 | $this->useTransaction(TRUE); |
3ed73cde | 47 | |
5896d037 TO |
48 | $this->_contactID = $this->organizationCreate(); |
49 | $activity = $this->activityCreate(); | |
50 | $this->_activityID = $activity['id']; | |
3ed73cde | 51 | CRM_Core_PseudoConstant::flush(); |
3ed73cde | 52 | $this->_params = array( |
53 | 'contact_id' => $this->_contactID, | |
54 | 'activity_id' => $this->_activityID, | |
55 | 'record_type_id' => 2, | |
56 | ); | |
57 | } | |
58 | ||
3ed73cde | 59 | public function testCreateActivityContact() { |
60 | ||
61 | $result = $this->callAPIAndDocument('activity_contact', 'create', $this->_params, __FUNCTION__, __FILE__); | |
62 | $this->assertEquals(1, $result['count']); | |
63 | $this->assertNotNull($result['values'][$result['id']]['id']); | |
64 | ||
65 | $this->callAPISuccess('activity_contact', 'delete', array('id' => $result['id'])); | |
66 | } | |
67 | ||
68 | public function testDeleteActivityContact() { | |
69 | //create one | |
70 | $create = $this->callAPISuccess('activity_contact', 'create', $this->_params); | |
71 | ||
6c6e6187 | 72 | $result = $this->callAPIAndDocument('activity_contact', 'delete', array('id' => $create['id']), __FUNCTION__, __FILE__); |
3ed73cde | 73 | $this->assertEquals(1, $result['count']); |
74 | $get = $this->callAPISuccess('activity_contact', 'get', array( | |
75 | 'id' => $create['id'], | |
76 | )); | |
77 | $this->assertEquals(0, $get['count'], 'ActivityContact not successfully deleted'); | |
78 | } | |
79 | ||
f0be539a EM |
80 | /** |
81 | * | |
82 | */ | |
3ed73cde | 83 | public function testGetActivitiesByContact() { |
f0be539a | 84 | $this->callAPISuccess('ActivityContact', 'Get', array('contact_id' => $this->_contactID)); |
3ed73cde | 85 | } |
86 | ||
f0be539a EM |
87 | public function testGetParticipantsByActivity() { |
88 | $this->callAPISuccess('ActivityContact', 'Get', array('activity_id' => $this->_activityID)); | |
3ed73cde | 89 | } |
90 | ||
91 | /** | |
92 | * Test civicrm_activity_contact_get with empty params. | |
93 | */ | |
94 | public function testGetEmptyParams() { | |
95 | $result = $this->callAPISuccess('ActivityContact', 'Get', array()); | |
96 | } | |
97 | ||
98 | /** | |
99 | * Test civicrm_activity_contact_get with wrong params. | |
100 | */ | |
101 | public function testGetWrongParams() { | |
102 | $this->callAPIFailure('ActivityContact', 'Get', array('contact_id' => 'abc')); | |
103 | $this->callAPIFailure('ActivityContact', 'Get', array('activity_id' => 'abc')); | |
104 | $this->callAPIFailure('ActivityContact', 'Get', array('record_type_id' => 'abc')); | |
105 | } | |
96025800 | 106 | |
3ed73cde | 107 | } |