a few phpcs fixups
[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
27require_once 'CiviTest/CiviUnitTestCase.php';
28
29/**
30 * Test APIv3 civicrm_activity_* functions
31 *
6c6e6187
TO
32 * @package CiviCRM_APIv3
33 * @subpackage API_Activity
6a488035 34 */
6a488035
TO
35class api_v3_ActivityTypeTest extends CiviUnitTestCase {
36 protected $_apiversion;
b7c9bc4c 37
00be9182 38 public function setUp() {
6a488035
TO
39 $this->_apiversion = 3;
40 CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name');
41 parent::setUp();
cfba875b 42 $this->useTransaction(TRUE);
6a488035
TO
43 }
44
45 /**
d177a2a6 46 * Test civicrm_activity_type_get().
6a488035 47 */
00be9182 48 public function testActivityTypeGet() {
4e420887 49 $params = array();
50 $result = $this->callAPIAndDocument('activity_type', 'get', $params, __FUNCTION__, __FILE__);
6a488035
TO
51 $this->assertEquals($result['values']['1'], 'Meeting', 'In line ' . __LINE__);
52 $this->assertEquals($result['values']['13'], 'Open Case', 'In line ' . __LINE__);
53 }
54
55 /**
d177a2a6 56 * Test civicrm_activity_type_create().
6a488035 57 */
00be9182 58 public function testActivityTypeCreate() {
6a488035
TO
59 $params = array(
60 'weight' => '2',
61 'label' => 'send out letters',
6a488035
TO
62 'filter' => 0,
63 'is_active' => 1,
64 'is_optgroup' => 1,
65 'is_default' => 0,
66 );
4e420887 67 $result = $this->callAPIAndDocument('activity_type', 'create', $params, __FUNCTION__, __FILE__);
6a488035
TO
68 }
69
70 /**
d177a2a6 71 * Test civicrm_activity_type_create - check id
6a488035 72 */
00be9182 73 public function testActivityTypecreatecheckId() {
6a488035
TO
74 $params = array(
75 'label' => 'type_create',
76 'weight' => '2',
6a488035 77 );
4e420887 78 $activitycreate = $this->callAPISuccess('activity_type', 'create', $params);
6a488035
TO
79 $this->assertArrayHasKey('id', $activitycreate);
80 $this->assertArrayHasKey('option_group_id', $activitycreate['values'][$activitycreate['id']]);
81 }
82
83 /**
d177a2a6 84 * Test civicrm_activity_type_delete()
6a488035 85 */
00be9182 86 public function testActivityTypeDelete() {
6a488035
TO
87 $params = array(
88 'label' => 'type_create_delete',
89 'weight' => '2',
6a488035 90 );
4e420887 91 $activitycreate = $this->callAPISuccess('activity_type', 'create', $params);
6a488035
TO
92 $params = array(
93 'activity_type_id' => $activitycreate['id'],
6a488035 94 );
4e420887 95 $result = $this->callAPISuccess('activity_type', 'delete', $params, __FUNCTION__, __FILE__);
6a488035 96 }
96025800 97
6a488035 98}