Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /** | |
3 | * File for the TestConstant class | |
4 | * | |
5 | * (PHP 5) | |
6 | * | |
6c6e6187 TO |
7 | * @author Walt Haas <walt@dharmatech.org> (801) 534-1262 |
8 | * @copyright Copyright CiviCRM LLC (C) 2009 | |
9 | * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html | |
6a488035 | 10 | * GNU Affero General Public License version 3 |
6c6e6187 TO |
11 | * @version $Id: ConstantTest.php 31254 2010-12-15 10:09:29Z eileen $ |
12 | * @package CiviCRM_APIv3 | |
13 | * @subpackage API_Constant | |
6a488035 TO |
14 | * |
15 | * This file is part of CiviCRM | |
16 | * | |
17 | * CiviCRM is free software; you can redistribute it and/or | |
18 | * modify it under the terms of the GNU Affero General Public License | |
19 | * as published by the Free Software Foundation; either version 3 of | |
20 | * the License, or (at your option) any later version. | |
21 | * | |
22 | * CiviCRM is distributed in the hope that it will be useful, | |
23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 | * GNU Affero General Public License for more details. | |
26 | * | |
27 | * You should have received a copy of the GNU Affero General Public | |
28 | * License along with this program. If not, see | |
29 | * <http://www.gnu.org/licenses/>. | |
30 | */ | |
31 | ||
6a488035 TO |
32 | /** |
33 | * Test APIv3 civicrm_activity_* functions | |
34 | * | |
6c6e6187 TO |
35 | * @package CiviCRM_APIv3 |
36 | * @subpackage API_Constant | |
acb109b7 | 37 | * @group headless |
6a488035 TO |
38 | */ |
39 | class api_v3_ConstantTest extends CiviUnitTestCase { | |
b7c9bc4c | 40 | |
6a488035 | 41 | /** |
eceb18cc | 42 | * Test setup for every test. |
6a488035 | 43 | * |
d177a2a6 EM |
44 | * Connect to the database, truncate the tables that will be used |
45 | * and redirect stdin to a temporary file | |
6a488035 | 46 | */ |
7ef12efc | 47 | public function setUp(): void { |
6a488035 TO |
48 | // Connect to the database |
49 | parent::setUp(); | |
6a488035 TO |
50 | } |
51 | ||
52 | /** | |
d177a2a6 | 53 | * Test civicrm_constant_get( ) for unknown constant |
6a488035 TO |
54 | */ |
55 | public function testUnknownConstant() { | |
9099cab3 | 56 | $result = $this->callAPIFailure('constant', 'get', [ |
6a488035 | 57 | 'name' => 'thisTypeDoesNotExist', |
9099cab3 | 58 | ]); |
6a488035 TO |
59 | } |
60 | ||
61 | /** | |
d177a2a6 | 62 | * Test civicrm_constant_get( 'activityStatus' ) |
6a488035 TO |
63 | */ |
64 | public function testActivityStatus() { | |
65 | ||
9099cab3 | 66 | $result = $this->callAPISuccess('constant', 'get', [ |
6a488035 | 67 | 'name' => 'activityStatus', |
9099cab3 | 68 | ]); |
6a488035 TO |
69 | |
70 | $this->assertTrue($result['count'] > 5, "In line " . __LINE__); | |
71 | $this->assertContains('Scheduled', $result['values'], "In line " . __LINE__); | |
72 | $this->assertContains('Completed', $result['values'], "In line " . __LINE__); | |
73 | $this->assertContains('Cancelled', $result['values'], "In line " . __LINE__); | |
74 | ||
6a488035 TO |
75 | } |
76 | ||
77 | /** | |
d177a2a6 | 78 | * Test civicrm_constant_get( 'activityType' ) |
6a488035 TO |
79 | */ |
80 | public function testActivityType() { | |
9099cab3 | 81 | $result = $this->callAPIAndDocument('constant', 'get', [ |
6a488035 | 82 | 'name' => 'activityType', |
9099cab3 | 83 | ], __FUNCTION__, __FILE__, NULL, NULL, 'get'); |
6a488035 TO |
84 | $this->assertTrue($result['count'] > 2, "In line " . __LINE__); |
85 | $this->assertContains('Meeting', $result['values'], "In line " . __LINE__); | |
6a488035 TO |
86 | } |
87 | ||
88 | /** | |
d177a2a6 | 89 | * Test civicrm_address_getoptions( 'location_type_id' ) |
2d932085 CW |
90 | * @param int $version |
91 | * @dataProvider versionThreeAndFour | |
6a488035 | 92 | */ |
2d932085 CW |
93 | public function testLocationTypeGet($version) { |
94 | $this->_apiversion = $version; | |
6a488035 | 95 | // needed to get rid of cached values from previous tests |
2683ce94 | 96 | CRM_Core_PseudoConstant::flush(); |
6a488035 | 97 | |
9099cab3 | 98 | $params = [ |
1f4bb601 | 99 | 'field' => 'location_type_id', |
9099cab3 | 100 | ]; |
a828d7b8 | 101 | $result = $this->callAPIAndDocument('address', 'getoptions', $params, __FUNCTION__, __FILE__); |
6a488035 TO |
102 | $this->assertTrue($result['count'] > 3, "In line " . __LINE__); |
103 | $this->assertContains('Home', $result['values'], "In line " . __LINE__); | |
104 | $this->assertContains('Work', $result['values'], "In line " . __LINE__); | |
105 | $this->assertContains('Main', $result['values'], "In line " . __LINE__); | |
106 | $this->assertContains('Billing', $result['values'], "In line " . __LINE__); | |
6a488035 TO |
107 | } |
108 | ||
109 | /** | |
d177a2a6 | 110 | * Test civicrm_phone_getoptions( 'phone_type_id' ) |
2d932085 CW |
111 | * @param int $version |
112 | * @dataProvider versionThreeAndFour | |
6a488035 | 113 | */ |
2d932085 CW |
114 | public function testPhoneType($version) { |
115 | $this->_apiversion = $version; | |
9099cab3 | 116 | $params = [ |
1f4bb601 | 117 | 'field' => 'phone_type_id', |
9099cab3 | 118 | ]; |
a828d7b8 | 119 | $result = $this->callAPIAndDocument('phone', 'getoptions', $params, __FUNCTION__, __FILE__); |
6a488035 TO |
120 | |
121 | $this->assertEquals(5, $result['count'], "In line " . __LINE__); | |
122 | $this->assertContains('Phone', $result['values'], "In line " . __LINE__); | |
123 | $this->assertContains('Mobile', $result['values'], "In line " . __LINE__); | |
124 | $this->assertContains('Fax', $result['values'], "In line " . __LINE__); | |
125 | $this->assertContains('Pager', $result['values'], "In line " . __LINE__); | |
126 | $this->assertContains('Voicemail', $result['values'], "In line " . __LINE__); | |
6a488035 TO |
127 | } |
128 | ||
129 | /** | |
d177a2a6 | 130 | * Test civicrm_constant_get( 'mailProtocol' ) |
2d932085 CW |
131 | * @param int $version |
132 | * @dataProvider versionThreeAndFour | |
6a488035 | 133 | */ |
2d932085 CW |
134 | public function testmailProtocol($version) { |
135 | $this->_apiversion = $version; | |
9099cab3 | 136 | $params = [ |
1f4bb601 | 137 | 'field' => 'protocol', |
9099cab3 | 138 | ]; |
a828d7b8 | 139 | $result = $this->callAPIAndDocument('mail_settings', 'getoptions', $params, __FUNCTION__, __FILE__); |
6a488035 | 140 | |
fd9b149f | 141 | $this->assertEquals(4, $result['count'], "In line " . __LINE__); |
6a488035 TO |
142 | $this->assertContains('IMAP', $result['values'], "In line " . __LINE__); |
143 | $this->assertContains('Maildir', $result['values'], "In line " . __LINE__); | |
144 | $this->assertContains('POP3', $result['values'], "In line " . __LINE__); | |
145 | $this->assertContains('Localdir', $result['values'], "In line " . __LINE__); | |
6a488035 | 146 | } |
96025800 | 147 | |
6a488035 | 148 | } |