Merge pull request #13926 from pradpnayak/NoticeErrorProfile
[civicrm-core.git] / tests / phpunit / api / v3 / ActivityTypeTest.php
CommitLineData
6a488035 1<?php
6a488035
TO
2
3/**
4 * File for the TestActivityType class
5 *
6 * (PHP 5)
7 *
6c6e6187 8 * @package CiviCRM
6a488035
TO
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
6a488035
TO
27/**
28 * Test APIv3 civicrm_activity_* functions
29 *
6c6e6187
TO
30 * @package CiviCRM_APIv3
31 * @subpackage API_Activity
acb109b7 32 * @group headless
6a488035 33 */
6a488035
TO
34class api_v3_ActivityTypeTest extends CiviUnitTestCase {
35 protected $_apiversion;
b7c9bc4c 36
00be9182 37 public function setUp() {
6a488035
TO
38 $this->_apiversion = 3;
39 CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name');
40 parent::setUp();
cfba875b 41 $this->useTransaction(TRUE);
6a488035
TO
42 }
43
44 /**
d177a2a6 45 * Test civicrm_activity_type_get().
6a488035 46 */
00be9182 47 public function testActivityTypeGet() {
4e420887 48 $params = array();
49 $result = $this->callAPIAndDocument('activity_type', 'get', $params, __FUNCTION__, __FILE__);
ba4a1892 50 $this->assertEquals($result['values']['1'], 'Meeting');
6a488035
TO
51 }
52
53 /**
d177a2a6 54 * Test civicrm_activity_type_create().
6a488035 55 */
00be9182 56 public function testActivityTypeCreate() {
6a488035
TO
57 $params = array(
58 'weight' => '2',
59 'label' => 'send out letters',
6a488035
TO
60 'filter' => 0,
61 'is_active' => 1,
62 'is_optgroup' => 1,
63 'is_default' => 0,
64 );
4e420887 65 $result = $this->callAPIAndDocument('activity_type', 'create', $params, __FUNCTION__, __FILE__);
6a488035
TO
66 }
67
68 /**
d177a2a6 69 * Test civicrm_activity_type_create - check id
6a488035 70 */
00be9182 71 public function testActivityTypecreatecheckId() {
6a488035
TO
72 $params = array(
73 'label' => 'type_create',
74 'weight' => '2',
6a488035 75 );
4e420887 76 $activitycreate = $this->callAPISuccess('activity_type', 'create', $params);
6a488035
TO
77 $this->assertArrayHasKey('id', $activitycreate);
78 $this->assertArrayHasKey('option_group_id', $activitycreate['values'][$activitycreate['id']]);
79 }
80
81 /**
d177a2a6 82 * Test civicrm_activity_type_delete()
6a488035 83 */
00be9182 84 public function testActivityTypeDelete() {
6a488035
TO
85 $params = array(
86 'label' => 'type_create_delete',
87 'weight' => '2',
6a488035 88 );
4e420887 89 $activitycreate = $this->callAPISuccess('activity_type', 'create', $params);
6a488035
TO
90 $params = array(
91 'activity_type_id' => $activitycreate['id'],
6a488035 92 );
4e420887 93 $result = $this->callAPISuccess('activity_type', 'delete', $params, __FUNCTION__, __FILE__);
6a488035 94 }
96025800 95
6a488035 96}