Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | |
3 | /** | |
4 | * File for the TestActivityType class | |
5 | * | |
6 | * (PHP 5) | |
7 | * | |
8 | * @package CiviCRM | |
9 | * | |
10 | * This file is part of CiviCRM | |
11 | * | |
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. | |
16 | * | |
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. | |
21 | * | |
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/>. | |
25 | */ | |
26 | ||
27 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
28 | ||
29 | /** | |
30 | * Test APIv3 civicrm_activity_* functions | |
31 | * | |
32 | * @package CiviCRM_APIv3 | |
33 | * @subpackage API_Activity | |
34 | */ | |
35 | ||
36 | class api_v3_ActivityTypeTest extends CiviUnitTestCase { | |
37 | protected $_apiversion; | |
b7c9bc4c | 38 | |
6a488035 | 39 | |
4cbe18b8 EM |
40 | /** |
41 | * @return array | |
42 | */ | |
6a488035 TO |
43 | function get_info() { |
44 | return array( | |
45 | 'name' => 'Activity Type', | |
46 | 'description' => 'Test all ActivityType Get/Create/Delete methods.', | |
47 | 'group' => 'CiviCRM API Tests', | |
48 | ); | |
49 | } | |
50 | ||
51 | function setUp() { | |
52 | $this->_apiversion = 3; | |
53 | CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name'); | |
54 | parent::setUp(); | |
55 | } | |
56 | ||
57 | /** | |
58 | * Test civicrm_activity_type_get() | |
59 | */ | |
60 | function testActivityTypeGet() { | |
4e420887 | 61 | $params = array(); |
62 | $result = $this->callAPIAndDocument('activity_type', 'get', $params, __FUNCTION__, __FILE__); | |
6a488035 TO |
63 | $this->assertEquals($result['values']['1'], 'Meeting', 'In line ' . __LINE__); |
64 | $this->assertEquals($result['values']['13'], 'Open Case', 'In line ' . __LINE__); | |
65 | } | |
66 | ||
67 | /** | |
68 | * Test civicrm_activity_type_create() | |
69 | */ | |
70 | function testActivityTypeCreate() { | |
71 | ||
72 | $params = array( | |
73 | 'weight' => '2', | |
74 | 'label' => 'send out letters', | |
6a488035 TO |
75 | 'filter' => 0, |
76 | 'is_active' => 1, | |
77 | 'is_optgroup' => 1, | |
78 | 'is_default' => 0, | |
79 | ); | |
4e420887 | 80 | $result = $this->callAPIAndDocument('activity_type', 'create', $params, __FUNCTION__, __FILE__); |
6a488035 TO |
81 | } |
82 | ||
83 | /** | |
84 | * Test civicrm_activity_type_create - check id | |
85 | */ | |
86 | function testActivityTypecreatecheckId() { | |
87 | ||
88 | $params = array( | |
89 | 'label' => 'type_create', | |
90 | 'weight' => '2', | |
6a488035 | 91 | ); |
4e420887 | 92 | $activitycreate = $this->callAPISuccess('activity_type', 'create', $params); |
6a488035 TO |
93 | $this->assertArrayHasKey('id', $activitycreate); |
94 | $this->assertArrayHasKey('option_group_id', $activitycreate['values'][$activitycreate['id']]); | |
95 | } | |
96 | ||
97 | /** | |
98 | * Test civicrm_activity_type_delete() | |
99 | */ | |
100 | function testActivityTypeDelete() { | |
101 | ||
102 | $params = array( | |
103 | 'label' => 'type_create_delete', | |
104 | 'weight' => '2', | |
6a488035 | 105 | ); |
4e420887 | 106 | $activitycreate = $this->callAPISuccess('activity_type', 'create', $params); |
6a488035 TO |
107 | $params = array( |
108 | 'activity_type_id' => $activitycreate['id'], | |
6a488035 | 109 | ); |
4e420887 | 110 | $result = $this->callAPISuccess('activity_type', 'delete', $params, __FUNCTION__, __FILE__); |
6a488035 TO |
111 | } |
112 | } | |
113 |