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 | ||
32 | /** | |
33 | * Include class definitions | |
34 | */ | |
35 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
6a488035 TO |
36 | |
37 | /** | |
38 | * Test APIv3 civicrm_activity_* functions | |
39 | * | |
6c6e6187 TO |
40 | * @package CiviCRM_APIv3 |
41 | * @subpackage API_Constant | |
6a488035 TO |
42 | */ |
43 | class api_v3_ConstantTest extends CiviUnitTestCase { | |
44 | protected $_apiversion = 3; | |
b7c9bc4c | 45 | |
6a488035 TO |
46 | /** |
47 | * Test setup for every test | |
48 | * | |
49 | * Connect to the database, truncate the tables that will be used | |
50 | * and redirect stdin to a temporary file | |
51 | */ | |
52 | public function setUp() { | |
53 | // Connect to the database | |
54 | parent::setUp(); | |
55 | $this->_apiversion = 3; | |
56 | } | |
57 | ||
58 | /** | |
59 | * Test civicrm_constant_get( ) for unknown constant | |
60 | */ | |
61 | public function testUnknownConstant() { | |
fc928539 | 62 | $result = $this->callAPIFailure('constant', 'get', array( |
6a488035 | 63 | 'name' => 'thisTypeDoesNotExist', |
fc928539 | 64 | )); |
6a488035 TO |
65 | } |
66 | ||
67 | /** | |
68 | * Test civicrm_constant_get( 'activityStatus' ) | |
69 | */ | |
70 | public function testActivityStatus() { | |
71 | ||
fc928539 | 72 | $result = $this->callAPISuccess('constant', 'get', array( |
6a488035 | 73 | 'name' => 'activityStatus', |
fc928539 | 74 | )); |
6a488035 TO |
75 | |
76 | $this->assertTrue($result['count'] > 5, "In line " . __LINE__); | |
77 | $this->assertContains('Scheduled', $result['values'], "In line " . __LINE__); | |
78 | $this->assertContains('Completed', $result['values'], "In line " . __LINE__); | |
79 | $this->assertContains('Cancelled', $result['values'], "In line " . __LINE__); | |
80 | ||
6a488035 TO |
81 | } |
82 | ||
83 | /** | |
84 | * Test civicrm_constant_get( 'activityType' ) | |
85 | */ | |
86 | public function testActivityType() { | |
87 | ||
88 | $parameters = array(TRUE, FALSE, TRUE); | |
89 | ||
fc928539 | 90 | $result = $this->callAPISuccess('constant', 'get', array( |
6a488035 | 91 | 'name' => 'activityType', |
fc928539 | 92 | )); |
6a488035 TO |
93 | $this->assertTrue($result['count'] > 2, "In line " . __LINE__); |
94 | $this->assertContains('Meeting', $result['values'], "In line " . __LINE__); | |
6a488035 TO |
95 | } |
96 | ||
97 | /** | |
1f4bb601 | 98 | * Test civicrm_address_getoptions( 'location_type_id' ) |
6a488035 TO |
99 | */ |
100 | public function testLocationTypeGet() { | |
101 | // needed to get rid of cached values from previous tests | |
2683ce94 | 102 | CRM_Core_PseudoConstant::flush(); |
6a488035 | 103 | |
6a488035 | 104 | $params = array( |
1f4bb601 | 105 | 'field' => 'location_type_id', |
6a488035 | 106 | ); |
fc928539 | 107 | $result = $this->callAPIAndDocument('address', 'getoptions', $params, __FUNCTION__, __FILE__); |
6a488035 TO |
108 | $this->assertTrue($result['count'] > 3, "In line " . __LINE__); |
109 | $this->assertContains('Home', $result['values'], "In line " . __LINE__); | |
110 | $this->assertContains('Work', $result['values'], "In line " . __LINE__); | |
111 | $this->assertContains('Main', $result['values'], "In line " . __LINE__); | |
112 | $this->assertContains('Billing', $result['values'], "In line " . __LINE__); | |
6a488035 TO |
113 | } |
114 | ||
115 | /** | |
1f4bb601 | 116 | * Test civicrm_phone_getoptions( 'phone_type_id' ) |
6a488035 TO |
117 | */ |
118 | public function testPhoneType() { | |
1f4bb601 CW |
119 | $params = array( |
120 | 'field' => 'phone_type_id', | |
1f4bb601 | 121 | ); |
fc928539 | 122 | $result = $this->callAPISuccess('phone', 'getoptions', $params); |
6a488035 TO |
123 | |
124 | $this->assertEquals(5, $result['count'], "In line " . __LINE__); | |
125 | $this->assertContains('Phone', $result['values'], "In line " . __LINE__); | |
126 | $this->assertContains('Mobile', $result['values'], "In line " . __LINE__); | |
127 | $this->assertContains('Fax', $result['values'], "In line " . __LINE__); | |
128 | $this->assertContains('Pager', $result['values'], "In line " . __LINE__); | |
129 | $this->assertContains('Voicemail', $result['values'], "In line " . __LINE__); | |
6a488035 TO |
130 | } |
131 | ||
132 | /** | |
133 | * Test civicrm_constant_get( 'mailProtocol' ) | |
134 | */ | |
135 | public function testmailProtocol() { | |
1f4bb601 CW |
136 | $params = array( |
137 | 'field' => 'protocol', | |
1f4bb601 | 138 | ); |
fc928539 | 139 | $result = $this->callAPISuccess('mail_settings', 'getoptions', $params); |
6a488035 TO |
140 | |
141 | $this->assertEquals(4, $result['count'], "In line " . __LINE__); | |
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 TO |
146 | } |
147 | } |