3 * File for the TestConstant class
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
10 * GNU Affero General Public License version 3
11 * @version $Id: ConstantTest.php 31254 2010-12-15 10:09:29Z eileen $
12 * @package CiviCRM_APIv3
13 * @subpackage API_Constant
15 * This file is part of CiviCRM
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.
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.
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/>.
33 * Include class definitions
35 require_once 'CiviTest/CiviUnitTestCase.php';
38 * Test APIv3 civicrm_activity_* functions
40 * @package CiviCRM_APIv3
41 * @subpackage API_Constant
43 class api_v3_ConstantTest
extends CiviUnitTestCase
{
44 protected $_apiversion = 3;
50 * Initialize configuration
51 */ function __construct() {
52 parent
::__construct();
56 * Test setup for every test
58 * Connect to the database, truncate the tables that will be used
59 * and redirect stdin to a temporary file
61 public function setUp() {
62 // Connect to the database
64 $this->_apiversion
= 3;
68 * Test civicrm_constant_get( ) for unknown constant
70 public function testUnknownConstant() {
71 $result = $this->callAPIFailure('constant', 'get', array(
72 'name' => 'thisTypeDoesNotExist',
77 * Test civicrm_constant_get( 'activityStatus' )
79 public function testActivityStatus() {
81 $result = $this->callAPISuccess('constant', 'get', array(
82 'name' => 'activityStatus',
85 $this->assertTrue($result['count'] > 5, "In line " . __LINE__
);
86 $this->assertContains('Scheduled', $result['values'], "In line " . __LINE__
);
87 $this->assertContains('Completed', $result['values'], "In line " . __LINE__
);
88 $this->assertContains('Cancelled', $result['values'], "In line " . __LINE__
);
93 * Test civicrm_constant_get( 'activityType' )
95 public function testActivityType() {
97 $parameters = array(TRUE, FALSE, TRUE);
99 $result = $this->callAPISuccess('constant', 'get', array(
100 'name' => 'activityType',
102 $this->assertTrue($result['count'] > 2, "In line " . __LINE__
);
103 $this->assertContains('Meeting', $result['values'], "In line " . __LINE__
);
107 * Test civicrm_address_getoptions( 'location_type_id' )
109 public function testLocationTypeGet() {
110 // needed to get rid of cached values from previous tests
111 CRM_Core_PseudoConstant
::flush();
114 'field' => 'location_type_id',
116 $result = $this->callAPIAndDocument('address', 'getoptions', $params, __FUNCTION__
, __FILE__
);
117 $this->assertTrue($result['count'] > 3, "In line " . __LINE__
);
118 $this->assertContains('Home', $result['values'], "In line " . __LINE__
);
119 $this->assertContains('Work', $result['values'], "In line " . __LINE__
);
120 $this->assertContains('Main', $result['values'], "In line " . __LINE__
);
121 $this->assertContains('Billing', $result['values'], "In line " . __LINE__
);
125 * Test civicrm_phone_getoptions( 'phone_type_id' )
127 public function testPhoneType() {
129 'field' => 'phone_type_id',
131 $result = $this->callAPISuccess('phone', 'getoptions', $params);
133 $this->assertEquals(5, $result['count'], "In line " . __LINE__
);
134 $this->assertContains('Phone', $result['values'], "In line " . __LINE__
);
135 $this->assertContains('Mobile', $result['values'], "In line " . __LINE__
);
136 $this->assertContains('Fax', $result['values'], "In line " . __LINE__
);
137 $this->assertContains('Pager', $result['values'], "In line " . __LINE__
);
138 $this->assertContains('Voicemail', $result['values'], "In line " . __LINE__
);
142 * Test civicrm_constant_get( 'mailProtocol' )
144 public function testmailProtocol() {
146 'field' => 'protocol',
148 $result = $this->callAPISuccess('mail_settings', 'getoptions', $params);
150 $this->assertEquals(4, $result['count'], "In line " . __LINE__
);
151 $this->assertContains('IMAP', $result['values'], "In line " . __LINE__
);
152 $this->assertContains('Maildir', $result['values'], "In line " . __LINE__
);
153 $this->assertContains('POP3', $result['values'], "In line " . __LINE__
);
154 $this->assertContains('Localdir', $result['values'], "In line " . __LINE__
);