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