3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
30 * Test APIv3 civicrm_activity_contact* functions
32 * @package CiviCRM_APIv3
33 * @subpackage API_Activity
35 class api_v3_ActivityContactTest
extends CiviUnitTestCase
{
36 protected $_apiversion;
37 protected $_contactID;
38 protected $_activityID;
42 public function setUp() {
43 $this->_apiversion
= 3;
45 $this->useTransaction(TRUE);
47 $this->_contactID
= $this->organizationCreate();
48 $activity = $this->activityCreate();
49 $this->_activityID
= $activity['id'];
50 CRM_Core_PseudoConstant
::flush();
51 $this->_params
= array(
52 'contact_id' => $this->_contactID
,
53 'activity_id' => $this->_activityID
,
54 'record_type_id' => 2,
58 public function testCreateActivityContact() {
60 $result = $this->callAPIAndDocument('activity_contact', 'create', $this->_params
, __FUNCTION__
, __FILE__
);
61 $this->assertEquals(1, $result['count']);
62 $this->assertNotNull($result['values'][$result['id']]['id']);
64 $this->callAPISuccess('activity_contact', 'delete', array('id' => $result['id']));
67 public function testDeleteActivityContact() {
69 $create = $this->callAPISuccess('activity_contact', 'create', $this->_params
);
71 $result = $this->callAPIAndDocument('activity_contact', 'delete', array('id' => $create['id']), __FUNCTION__
, __FILE__
);
72 $this->assertEquals(1, $result['count']);
73 $get = $this->callAPISuccess('activity_contact', 'get', array(
74 'id' => $create['id'],
76 $this->assertEquals(0, $get['count'], 'ActivityContact not successfully deleted');
82 public function testGetActivitiesByContact() {
83 $this->callAPISuccess('ActivityContact', 'Get', array('contact_id' => $this->_contactID
));
86 public function testGetParticipantsByActivity() {
87 $this->callAPISuccess('ActivityContact', 'Get', array('activity_id' => $this->_activityID
));
91 * Test civicrm_activity_contact_get with empty params.
93 public function testGetEmptyParams() {
94 $result = $this->callAPISuccess('ActivityContact', 'Get', array());
98 * Test civicrm_activity_contact_get with wrong params.
100 public function testGetWrongParams() {
101 $this->callAPIFailure('ActivityContact', 'Get', array('contact_id' => 'abc'));
102 $this->callAPIFailure('ActivityContact', 'Get', array('activity_id' => 'abc'));
103 $this->callAPIFailure('ActivityContact', 'Get', array('record_type_id' => 'abc'));