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; | |
38 | public $_eNoticeCompliant = TRUE; | |
39 | ||
40 | function get_info() { | |
41 | return array( | |
42 | 'name' => 'Activity Type', | |
43 | 'description' => 'Test all ActivityType Get/Create/Delete methods.', | |
44 | 'group' => 'CiviCRM API Tests', | |
45 | ); | |
46 | } | |
47 | ||
48 | function setUp() { | |
49 | $this->_apiversion = 3; | |
50 | CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name'); | |
51 | parent::setUp(); | |
52 | } | |
53 | ||
54 | /** | |
55 | * Test civicrm_activity_type_get() | |
56 | */ | |
57 | function testActivityTypeGet() { | |
4e420887 | 58 | $params = array(); |
59 | $result = $this->callAPIAndDocument('activity_type', 'get', $params, __FUNCTION__, __FILE__); | |
6a488035 TO |
60 | $this->assertEquals($result['values']['1'], 'Meeting', 'In line ' . __LINE__); |
61 | $this->assertEquals($result['values']['13'], 'Open Case', 'In line ' . __LINE__); | |
62 | } | |
63 | ||
64 | /** | |
65 | * Test civicrm_activity_type_create() | |
66 | */ | |
67 | function testActivityTypeCreate() { | |
68 | ||
69 | $params = array( | |
70 | 'weight' => '2', | |
71 | 'label' => 'send out letters', | |
6a488035 TO |
72 | 'filter' => 0, |
73 | 'is_active' => 1, | |
74 | 'is_optgroup' => 1, | |
75 | 'is_default' => 0, | |
76 | ); | |
4e420887 | 77 | $result = $this->callAPIAndDocument('activity_type', 'create', $params, __FUNCTION__, __FILE__); |
6a488035 TO |
78 | } |
79 | ||
80 | /** | |
81 | * Test civicrm_activity_type_create - check id | |
82 | */ | |
83 | function testActivityTypecreatecheckId() { | |
84 | ||
85 | $params = array( | |
86 | 'label' => 'type_create', | |
87 | 'weight' => '2', | |
6a488035 | 88 | ); |
4e420887 | 89 | $activitycreate = $this->callAPISuccess('activity_type', 'create', $params); |
6a488035 TO |
90 | $this->assertArrayHasKey('id', $activitycreate); |
91 | $this->assertArrayHasKey('option_group_id', $activitycreate['values'][$activitycreate['id']]); | |
92 | } | |
93 | ||
94 | /** | |
95 | * Test civicrm_activity_type_delete() | |
96 | */ | |
97 | function testActivityTypeDelete() { | |
98 | ||
99 | $params = array( | |
100 | 'label' => 'type_create_delete', | |
101 | 'weight' => '2', | |
6a488035 | 102 | ); |
4e420887 | 103 | $activitycreate = $this->callAPISuccess('activity_type', 'create', $params); |
6a488035 TO |
104 | $params = array( |
105 | 'activity_type_id' => $activitycreate['id'], | |
6a488035 | 106 | ); |
4e420887 | 107 | $result = $this->callAPISuccess('activity_type', 'delete', $params, __FUNCTION__, __FILE__); |
6a488035 TO |
108 | } |
109 | } | |
110 |