5 * File for the TestActivityType class
11 * This file is part of CiviCRM
13 * CiviCRM is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Affero General Public License
15 * as published by the Free Software Foundation; either version 3 of
16 * the License, or (at your option) any later version.
18 * CiviCRM is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Affero General Public License for more details.
23 * You should have received a copy of the GNU Affero General Public
24 * License along with this program. If not, see
25 * <http://www.gnu.org/licenses/>.
28 require_once 'CiviTest/CiviUnitTestCase.php';
31 * Test APIv3 civicrm_activity_* functions
33 * @package CiviCRM_APIv3
34 * @subpackage API_Activity
37 class api_v3_ActivityTypeTest
extends CiviUnitTestCase
{
38 protected $_apiversion;
39 public $_eNoticeCompliant = TRUE;
43 'name' => 'Activity Type',
44 'description' => 'Test all ActivityType Get/Create/Delete methods.',
45 'group' => 'CiviCRM API Tests',
50 $this->_apiversion
= 3;
51 CRM_Core_PseudoConstant
::activityType(TRUE, TRUE, TRUE, 'name');
56 * Test civicrm_activity_type_get()
58 function testActivityTypeGet() {
59 $params = array('version' => $this->_apiversion
);
60 $result = civicrm_api('activity_type', 'get', $params);
61 $this->documentMe($params, $result, __FUNCTION__
, __FILE__
);
62 $this->assertEquals($result['values']['1'], 'Meeting', 'In line ' . __LINE__
);
63 $this->assertEquals($result['values']['13'], 'Open Case', 'In line ' . __LINE__
);
67 * Test civicrm_activity_type_create()
69 function testActivityTypeCreate() {
73 'label' => 'send out letters',
74 'version' => $this->_apiversion
,
80 $result = civicrm_api('activity_type', 'create', $params);
81 $this->documentMe($params, $result, __FUNCTION__
, __FILE__
);
82 $this->assertEquals($result['is_error'], 0);
86 * Test civicrm_activity_type_create - check id
88 function testActivityTypecreatecheckId() {
91 'label' => 'type_create',
93 'version' => $this->_apiversion
,
95 $activitycreate = civicrm_api('activity_type', 'create', $params);
96 $activityID = $activitycreate['id'];
97 $this->assertAPISuccess($activitycreate, "in line " . __LINE__
);
98 $this->assertArrayHasKey('id', $activitycreate);
99 $this->assertArrayHasKey('option_group_id', $activitycreate['values'][$activitycreate['id']]);
103 * Test civicrm_activity_type_delete()
105 function testActivityTypeDelete() {
108 'label' => 'type_create_delete',
110 'version' => $this->_apiversion
,
112 $activitycreate = civicrm_api('activity_type', 'create', $params);
114 'activity_type_id' => $activitycreate['id'],
115 'version' => $this->_apiversion
,
117 $result = civicrm_api('activity_type', 'delete', $params);
118 $this->documentMe($params, $result, __FUNCTION__
, __FILE__
);
119 $this->assertEquals($result['is_error'], 1, 'In line ' . __LINE__
);