3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
14 * Test APIv3 civicrm_activity_contact* functions
16 * @package CiviCRM_APIv3
17 * @subpackage API_Activity
20 class api_v3_ActivityContactTest
extends CiviUnitTestCase
{
21 protected $_apiversion;
22 protected $_contactID;
23 protected $_activityID;
26 public function setUp() {
28 $this->useTransaction(TRUE);
30 $this->_contactID
= $this->organizationCreate();
31 $activity = $this->activityCreate();
32 $this->_activityID
= $activity['id'];
33 CRM_Core_PseudoConstant
::flush();
35 'contact_id' => $this->_contactID
,
36 'activity_id' => $this->_activityID
,
37 'record_type_id' => 2,
43 * @dataProvider versionThreeAndFour
45 public function testCreateActivityContact($version) {
46 $this->_apiversion
= $version;
48 $result = $this->callAPIAndDocument('activity_contact', 'create', $this->_params
, __FUNCTION__
, __FILE__
);
49 $this->assertEquals(1, $result['count']);
50 $this->assertNotNull($result['values'][$result['id']]['id']);
52 $this->callAPISuccess('activity_contact', 'delete', ['id' => $result['id']]);
57 * @dataProvider versionThreeAndFour
59 public function testDeleteActivityContact($version) {
60 $this->_apiversion
= $version;
62 $create = $this->callAPISuccess('activity_contact', 'create', $this->_params
);
64 $result = $this->callAPIAndDocument('activity_contact', 'delete', ['id' => $create['id']], __FUNCTION__
, __FILE__
);
65 $this->assertEquals(1, $result['count']);
66 $get = $this->callAPISuccess('activity_contact', 'get', [
67 'id' => $create['id'],
69 $this->assertEquals(0, $get['count'], 'ActivityContact not successfully deleted');
74 * @dataProvider versionThreeAndFour
76 public function testGetActivitiesByContact($version) {
77 $this->_apiversion
= $version;
78 $this->callAPISuccess('ActivityContact', 'Get', ['contact_id' => $this->_contactID
]);
83 * @dataProvider versionThreeAndFour
85 public function testGetActivitiesByActivity($version) {
86 $this->_apiversion
= $version;
87 $this->callAPISuccess('ActivityContact', 'Get', ['activity_id' => $this->_activityID
]);
91 * Test civicrm_activity_contact_get with empty params.
93 * @dataProvider versionThreeAndFour
95 public function testGetEmptyParams($version) {
96 $this->_apiversion
= $version;
97 $this->callAPISuccess('ActivityContact', 'Get', []);
101 * Test civicrm_activity_contact_get with wrong params.
104 public function testGetWrongParams() {
105 $this->callAPIFailure('ActivityContact', 'Get', ['contact_id' => 'abc']);
106 $this->callAPIFailure('ActivityContact', 'Get', ['activity_id' => 'abc']);
107 $this->callAPIFailure('ActivityContact', 'Get', ['record_type_id' => 'abc']);