4 * File for the TestActivityType class
10 * This file is part of CiviCRM
12 * CiviCRM is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Affero General Public License
14 * as published by the Free Software Foundation; either version 3 of
15 * the License, or (at your option) any later version.
17 * CiviCRM is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
22 * You should have received a copy of the GNU Affero General Public
23 * License along with this program. If not, see
24 * <http://www.gnu.org/licenses/>.
27 require_once 'CiviTest/CiviUnitTestCase.php';
30 * Test APIv3 civicrm_activity_* functions
32 * @package CiviCRM_APIv3
33 * @subpackage API_Activity
36 class api_v3_ActivityTypeTest
extends CiviUnitTestCase
{
37 protected $_apiversion;
38 public $_eNoticeCompliant = TRUE;
42 'name' => 'Activity Type',
43 'description' => 'Test all ActivityType Get/Create/Delete methods.',
44 'group' => 'CiviCRM API Tests',
49 $this->_apiversion
= 3;
50 CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, TRUE, 'name');
55 * Test civicrm_activity_type_get()
57 function testActivityTypeGet() {
58 $params = array('version' => $this->_apiversion
);
59 $result = civicrm_api('activity_type', 'get', $params);
60 $this->documentMe($params, $result, __FUNCTION__
, __FILE__
);
61 $this->assertEquals($result['values']['1'], 'Meeting', 'In line ' . __LINE__
);
62 $this->assertEquals($result['values']['13'], 'Open Case', 'In line ' . __LINE__
);
66 * Test civicrm_activity_type_create()
68 function testActivityTypeCreate() {
72 'label' => 'send out letters',
73 'version' => $this->_apiversion
,
79 $result = civicrm_api('activity_type', 'create', $params);
80 $this->documentMe($params, $result, __FUNCTION__
, __FILE__
);
81 $this->assertAPISuccess($result);
85 * Test civicrm_activity_type_create - check id
87 function testActivityTypecreatecheckId() {
90 'label' => 'type_create',
92 'version' => $this->_apiversion
,
94 $activitycreate = civicrm_api('activity_type', 'create', $params);
95 $activityID = $activitycreate['id'];
96 $this->assertAPISuccess($activitycreate, "in line " . __LINE__
);
97 $this->assertArrayHasKey('id', $activitycreate);
98 $this->assertArrayHasKey('option_group_id', $activitycreate['values'][$activitycreate['id']]);
102 * Test civicrm_activity_type_delete()
104 function testActivityTypeDelete() {
107 'label' => 'type_create_delete',
109 'version' => $this->_apiversion
,
111 $activitycreate = civicrm_api('activity_type', 'create', $params);
113 'activity_type_id' => $activitycreate['id'],
114 'version' => $this->_apiversion
,
116 $result = civicrm_api('activity_type', 'delete', $params);
117 $this->documentMe($params, $result, __FUNCTION__
, __FILE__
);
118 $this->assertAPIFailure($result, 'In line ' . __LINE__
);