CRM-13014 support userLoginFinalize() for UF classes (fix civimobile)
[civicrm-core.git] / tests / phpunit / api / v3 / ActivityTypeTest.php
1 <?php
2 // $Id$
3
4 /**
5 * File for the TestActivityType class
6 *
7 * (PHP 5)
8 *
9 * @package CiviCRM
10 *
11 * This file is part of CiviCRM
12 *
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.
17 *
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.
22 *
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/>.
26 */
27
28 require_once 'CiviTest/CiviUnitTestCase.php';
29
30 /**
31 * Test APIv3 civicrm_activity_* functions
32 *
33 * @package CiviCRM_APIv3
34 * @subpackage API_Activity
35 */
36
37 class api_v3_ActivityTypeTest extends CiviUnitTestCase {
38 protected $_apiversion;
39 public $_eNoticeCompliant = TRUE;
40
41 function get_info() {
42 return array(
43 'name' => 'Activity Type',
44 'description' => 'Test all ActivityType Get/Create/Delete methods.',
45 'group' => 'CiviCRM API Tests',
46 );
47 }
48
49 function setUp() {
50 $this->_apiversion = 3;
51 CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name');
52 parent::setUp();
53 }
54
55 /**
56 * Test civicrm_activity_type_get()
57 */
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__);
64 }
65
66 /**
67 * Test civicrm_activity_type_create()
68 */
69 function testActivityTypeCreate() {
70
71 $params = array(
72 'weight' => '2',
73 'label' => 'send out letters',
74 'version' => $this->_apiversion,
75 'filter' => 0,
76 'is_active' => 1,
77 'is_optgroup' => 1,
78 'is_default' => 0,
79 );
80 $result = civicrm_api('activity_type', 'create', $params);
81 $this->documentMe($params, $result, __FUNCTION__, __FILE__);
82 $this->assertEquals($result['is_error'], 0);
83 }
84
85 /**
86 * Test civicrm_activity_type_create - check id
87 */
88 function testActivityTypecreatecheckId() {
89
90 $params = array(
91 'label' => 'type_create',
92 'weight' => '2',
93 'version' => $this->_apiversion,
94 );
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']]);
100 }
101
102 /**
103 * Test civicrm_activity_type_delete()
104 */
105 function testActivityTypeDelete() {
106
107 $params = array(
108 'label' => 'type_create_delete',
109 'weight' => '2',
110 'version' => $this->_apiversion,
111 );
112 $activitycreate = civicrm_api('activity_type', 'create', $params);
113 $params = array(
114 'activity_type_id' => $activitycreate['id'],
115 'version' => $this->_apiversion,
116 );
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__);
120 }
121 }
122