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