Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2014-12-30-00-43-32
[civicrm-core.git] / tests / phpunit / api / v3 / ActivityTypeTest.php
1 <?php
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
39 function setUp() {
40 $this->_apiversion = 3;
41 CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name');
42 parent::setUp();
43 $this->useTransaction(TRUE);
44 }
45
46 /**
47 * Test civicrm_activity_type_get()
48 */
49 function testActivityTypeGet() {
50 $params = array();
51 $result = $this->callAPIAndDocument('activity_type', 'get', $params, __FUNCTION__, __FILE__);
52 $this->assertEquals($result['values']['1'], 'Meeting', 'In line ' . __LINE__);
53 $this->assertEquals($result['values']['13'], 'Open Case', 'In line ' . __LINE__);
54 }
55
56 /**
57 * Test civicrm_activity_type_create()
58 */
59 function testActivityTypeCreate() {
60 $params = array(
61 'weight' => '2',
62 'label' => 'send out letters',
63 'filter' => 0,
64 'is_active' => 1,
65 'is_optgroup' => 1,
66 'is_default' => 0,
67 );
68 $result = $this->callAPIAndDocument('activity_type', 'create', $params, __FUNCTION__, __FILE__);
69 }
70
71 /**
72 * Test civicrm_activity_type_create - check id
73 */
74 function testActivityTypecreatecheckId() {
75 $params = array(
76 'label' => 'type_create',
77 'weight' => '2',
78 );
79 $activitycreate = $this->callAPISuccess('activity_type', 'create', $params);
80 $this->assertArrayHasKey('id', $activitycreate);
81 $this->assertArrayHasKey('option_group_id', $activitycreate['values'][$activitycreate['id']]);
82 }
83
84 /**
85 * Test civicrm_activity_type_delete()
86 */
87 function testActivityTypeDelete() {
88 $params = array(
89 'label' => 'type_create_delete',
90 'weight' => '2',
91 );
92 $activitycreate = $this->callAPISuccess('activity_type', 'create', $params);
93 $params = array(
94 'activity_type_id' => $activitycreate['id'],
95 );
96 $result = $this->callAPISuccess('activity_type', 'delete', $params, __FUNCTION__, __FILE__);
97 }
98 }
99