fix mis-spellings & undeclared variables
[civicrm-core.git] / tests / phpunit / api / v3 / SettingTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
232624b1 4 | CiviCRM version 4.4 |
6a488035
TO
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26*/
27
28require_once 'CiviTest/CiviUnitTestCase.php';
29
30
31/**
32 * Test APIv3 civicrm_setting_* functions
33 *
34 * @package CiviCRM_APIv3
35 * @subpackage API_Core
36 */
37
38/**
39 * Class contains api test cases for civicrm settings
40 *
41 */
42class api_v3_SettingTest extends CiviUnitTestCase {
43
44 protected $_apiversion = 3;
45 protected $_contactID;
46 protected $_params;
47 protected $_currentDomain;
48 protected $_domainID2;
49 protected $_domainID3;
b7c9bc4c 50
6a488035
TO
51 function __construct() {
52 parent::__construct();
53
54 }
55
56 function get_info() {
57 return array(
58 'name' => 'Settings Tests',
59 'description' => 'Settings API',
60 'group' => 'CiviCRM API Tests',
61 );
62 }
63
64 function setUp() {
65 parent::setUp();
66 $params = array(
67 'name' => 'Default Domain Name',
7fbb4198 68 );
69 $result = $this->callAPISuccess( 'domain','get',$params);
6a488035 70 if(empty($result['id'])){
7fbb4198 71 $result = $this->callAPISuccess( 'domain','create',$params );
6a488035
TO
72 }
73
74 $params['name'] = 'Second Domain';
7fbb4198 75 $result = $this->callAPISuccess( 'domain','get',$params);
6a488035 76 if(empty($result['id'])){
7fbb4198 77 $result = $this->callAPISuccess( 'domain','create',$params );
6a488035
TO
78 }
79 $this->_domainID2 = $result['id'];
80 $params['name'] = 'A-team domain';
7fbb4198 81 $result = $this->callAPISuccess( 'domain','get',$params);
6a488035 82 if(empty($result['id'])){
7fbb4198 83 $result = $this->callAPISuccess( 'domain','create',$params );
6a488035
TO
84 }
85 $this->_domainID3 = $result['id'];
86 $this->_currentDomain = CRM_Core_Config::domainID();
87 }
88
89 function tearDown() {
90 parent::tearDown();
7fbb4198 91 $this->callAPISuccess('system','flush', array());
6a488035 92 $this->quickCleanup(array('civicrm_domain'));
6a488035
TO
93 }
94
95 /**
96 * check getfields works
97 */
98 function testGetFields() {
6a488035 99 $description = 'Demonstrate return from getfields - see subfolder for variants';
7fbb4198 100 $result = $this->callAPIAndDocument('setting', 'getfields', array(), __FUNCTION__, __FILE__, $description);
6a488035
TO
101 $this->assertArrayHasKey('customCSSURL', $result['values']);
102
103 $description = 'Demonstrate return from getfields';
7fbb4198 104 $result = $this->callAPISuccess('setting', 'getfields', array());
6a488035 105 $this->assertArrayHasKey('customCSSURL', $result['values']);
7fbb4198 106 $this->callAPISuccess('system','flush', array());
6a488035
TO
107 }
108
109 /**
110 * let's check it's loading from cache by meddling with the cache
111 */
112 function testGetFieldsCaching() {
113 $settingsMetadata = array();
114 CRM_Core_BAO_Cache::setItem($settingsMetadata,'CiviCRM setting Specs', 'settingsMetadata__');
115 CRM_Core_BAO_Cache::setItem($settingsMetadata,'CiviCRM setting Spec', 'All');
7fbb4198 116 $result = $this->callAPISuccess('setting', 'getfields', array());
6a488035
TO
117 $this->assertArrayNotHasKey('customCSSURL', $result['values']);
118 $this->quickCleanup(array('civicrm_cache'));
119 }
120
121 function testGetFieldsFilters() {
7fbb4198 122 $params = array('name' => 'advanced_search_options');
123 $result = $this->callAPISuccess('setting', 'getfields', $params);
6a488035
TO
124 $this->assertArrayNotHasKey('customCSSURL', $result['values']);
125 $this->assertArrayHasKey('advanced_search_options',$result['values']);
4ed37178
E
126 }
127
128 /**
129 * Test that getfields will filter on group
130 */
131 function testGetFieldsGroupFilters() {
132 $params = array('filters' => array('group' => 'multisite'));
133 $result = $this->callAPISuccess('setting', 'getfields', $params);
134 $this->assertArrayNotHasKey('customCSSURL', $result['values']);
135 $this->assertArrayHasKey('domain_group_id',$result['values']);
136 }
137
138 /**
139 * Test that getfields will filter on another field (prefetch)
140 */
141 function testGetFieldsPrefetchFilters() {
142 $params = array('filters' => array('prefetch' => 1));
143 $result = $this->callAPISuccess('setting', 'getfields', $params);
144 $this->assertArrayNotHasKey('disable_mandatory_tokens_check', $result['values']);
145 $this->assertArrayHasKey('monetaryDecimalPoint',$result['values']);
6a488035 146 }
076d8c82
TO
147
148 /**
149 * Ensure that on_change callbacks fire.
150 *
151 * Note: api_v3_SettingTest::testOnChange and CRM_Core_BAO_SettingTest::testOnChange
152 * are very similar, but they exercise different codepaths. The first uses the API
153 * and setItems [plural]; the second uses setItem [singular].
154 */
155 function testOnChange() {
156 global $_testOnChange_hookCalls;
157 $this->setMockSettingsMetaData(array(
158 'onChangeExample' => array(
159 'group_name' => 'CiviCRM Preferences',
160 'group' => 'core',
161 'name' => 'onChangeExample',
162 'type' => 'Array',
163 'quick_form_type' => 'Element',
164 'html_type' => 'advmultiselect',
165 'default' => array('CiviEvent', 'CiviContribute'),
166 'add' => '4.4',
167 'title' => 'List of Components',
168 'is_domain' => '1',
169 'is_contact' => 0,
170 'description' => NULL,
171 'help_text' => NULL,
172 'on_change' => array( // list of callbacks
173 array(__CLASS__, '_testOnChange_onChangeExample')
174 ),
175 ),
176 ));
177
178 // set initial value
179 $_testOnChange_hookCalls = array('count' => 0);
180 $this->callAPISuccess('setting', 'create', array(
181 'onChangeExample' => array('First', 'Value'),
182 ));
183 $this->assertEquals(1, $_testOnChange_hookCalls['count']);
184 $this->assertEquals(array('First', 'Value'), $_testOnChange_hookCalls['newValue']);
185 $this->assertEquals('List of Components', $_testOnChange_hookCalls['metadata']['title']);
186
187 // change value
188 $_testOnChange_hookCalls = array('count' => 0);
189 $this->callAPISuccess('setting', 'create', array(
190 'onChangeExample' => array('Second', 'Value'),
191 ));
192 $this->assertEquals(1, $_testOnChange_hookCalls['count']);
193 $this->assertEquals(array('First', 'Value'), $_testOnChange_hookCalls['oldValue']);
194 $this->assertEquals(array('Second', 'Value'), $_testOnChange_hookCalls['newValue']);
195 $this->assertEquals('List of Components', $_testOnChange_hookCalls['metadata']['title']);
196 }
197
198 /**
199 * Mock callback for a setting's on_change handler
200 *
201 * @param $oldValue
202 * @param $newValue
203 * @param $metadata
204 */
205 static function _testOnChange_onChangeExample($oldValue, $newValue, $metadata) {
206 global $_testOnChange_hookCalls;
207 $_testOnChange_hookCalls['count']++;
208 $_testOnChange_hookCalls['oldValue'] = $oldValue;
209 $_testOnChange_hookCalls['newValue'] = $newValue;
210 $_testOnChange_hookCalls['metadata'] = $metadata;
211 }
212
6a488035
TO
213 /**
214 * check getfields works
215 */
216 function testCreateSetting() {
7fbb4198 217 $description = "shows setting a variable for a given domain - if no domain is set current is assumed";
6a488035 218
7fbb4198 219 $params = array(
6a488035
TO
220 'domain_id' => $this->_domainID2,
221 'uniq_email_per_site' => 1,
222 );
7fbb4198 223 $result = $this->callAPIAndDocument('setting', 'create', $params, __FUNCTION__, __FILE__);
6a488035 224
7fbb4198 225 $params = array('uniq_email_per_site' => 1,);
6a488035 226 $description = "shows setting a variable for a current domain";
7fbb4198 227 $result = $this->callAPIAndDocument('setting', 'create', $params, __FUNCTION__, __FILE__, $description, 'CreateSettingCurrentDomain');
6a488035
TO
228 $this->assertArrayHasKey(CRM_Core_Config::domainID(), $result['values']);
229 }
230
231 /**
232 * check getfields works
233 */
234 function testCreateInvalidSettings() {
235
7fbb4198 236 $params = array(
6a488035
TO
237 'domain_id' => $this->_domainID2,
238 'invalid_key' => 1,
239 );
d0e1eff2 240 $result = $this->callAPIFailure('setting', 'create', $params);
6a488035
TO
241 }
242
243 /**
244 * check invalid settings rejected -
245 */
246
247 function testCreateInvalidURLSettings() {
248
7fbb4198 249 $params = array(
6a488035
TO
250 'domain_id' => $this->_domainID2,
251 'userFrameworkResourceURL' => 'dfhkdhfd',
252 );
d0e1eff2 253 $result = $this->callAPIFailure('setting', 'create', $params);
7fbb4198 254 $params = array(
6a488035
TO
255 'domain_id' => $this->_domainID2,
256 'userFrameworkResourceURL' => 'http://blah.com',
257 );
7fbb4198 258 $result = $this->callAPISuccess('setting', 'create', $params);
6a488035
TO
259 }
260
261 /**
262 * check getfields works
263 */
264 function testCreateInvalidBooleanSettings() {
265
7fbb4198 266 $params = array(
6a488035
TO
267 'domain_id' => $this->_domainID2,
268 'track_civimail_replies' => 'dfhkdhfd',
269 );
d0e1eff2 270 $result = $this->callAPIFailure('setting', 'create', $params);
6a488035 271
7fbb4198 272 $params = array('track_civimail_replies' => '0',);
273 $result = $this->callAPISuccess('setting', 'create', $params);
274 $getResult = $this->callAPISuccess('setting','get',$params);
6a488035
TO
275 $this->assertEquals(0, $getResult['values'][$this->_currentDomain]['track_civimail_replies']);
276
7fbb4198 277 $getResult = $this->callAPISuccess('setting','get',$params);
6a488035 278 $this->assertEquals(0, $getResult['values'][$this->_currentDomain]['track_civimail_replies']);
7fbb4198 279 $params = array( 'domain_id' => $this->_domainID2,
6a488035
TO
280 'track_civimail_replies' => '1',
281 );
7fbb4198 282 $result = $this->callAPISuccess('setting', 'create', $params);
283 $getResult = $this->callAPISuccess('setting','get',$params);
6a488035
TO
284 $this->assertEquals(1, $getResult['values'][$this->_domainID2]['track_civimail_replies']);
285
7fbb4198 286 $params = array(
6a488035
TO
287 'domain_id' => $this->_domainID2,
288 'track_civimail_replies' => 'TRUE',
289 );
7fbb4198 290 $result = $this->callAPISuccess('setting', 'create', $params);
291 $getResult = $this->callAPISuccess('setting','get',$params);
6a488035
TO
292
293 $this->assertEquals(1, $getResult['values'][$this->_domainID2]['track_civimail_replies'], "check TRUE is converted to 1");
294
295
296 }
297
298 /**
299 * check getfields works
300 */
301 function testCreateSettingMultipleDomains() {
7fbb4198 302 $description = "shows setting a variable for all domains";
6a488035 303
7fbb4198 304 $params = array(
6a488035
TO
305 'domain_id' => 'all',
306 'uniq_email_per_site' => 1,
6a488035 307 );
7fbb4198 308 $result = $this->callAPIAndDocument('setting', 'create', $params, __FUNCTION__, __FILE__,$description, 'CreateAllDomains');
309
6a488035
TO
310 $this->assertEquals(1, $result['values'][2]['uniq_email_per_site']);
311 $this->assertEquals(1, $result['values'][1]['uniq_email_per_site']);
312 $this->assertArrayHasKey(3, $result['values'], 'Domain create probably failed Debug this IF domain test is passing');
313 $this->assertEquals(1, $result['values'][3]['uniq_email_per_site'], 'failed to set setting for domain 3.');
314
7fbb4198 315 $params = array(
6a488035
TO
316 'domain_id' => 'all',
317 'return' => 'uniq_email_per_site'
318 );
319 // we'll check it with a 'get'
6a488035 320 $description = "shows getting a variable for all domains";
7fbb4198 321 $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__,$description, 'GetAllDomains', 'Get');
322
6a488035
TO
323 $this->assertEquals(1, $result['values'][2]['uniq_email_per_site']);
324 $this->assertEquals(1, $result['values'][1]['uniq_email_per_site']);
325 $this->assertEquals(1, $result['values'][3]['uniq_email_per_site']);
326
7fbb4198 327 $params = array(
6a488035
TO
328 'domain_id' => array(1,3),
329 'uniq_email_per_site' => 0,
330 );
6a488035 331 $description = "shows setting a variable for specified domains";
7fbb4198 332 $result = $this->callAPIAndDocument('setting', 'create', $params, __FUNCTION__, __FILE__,$description, 'CreateSpecifiedDomains');
333
6a488035
TO
334 $this->assertEquals(0, $result['values'][3]['uniq_email_per_site']);
335 $this->assertEquals(0, $result['values'][1]['uniq_email_per_site']);
7fbb4198 336 $params = array(
6a488035
TO
337 'domain_id' => array(1,2),
338 'return' => array('uniq_email_per_site'),
339 );
6a488035 340 $description = "shows getting a variable for specified domains";
7fbb4198 341 $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__,$description, 'GetSpecifiedDomains', 'Get');
6a488035
TO
342 $this->assertEquals(1, $result['values'][2]['uniq_email_per_site']);
343 $this->assertEquals(0, $result['values'][1]['uniq_email_per_site']);
344
345 }
346
347 function testGetSetting() {
348
7fbb4198 349 $params = array(
350 'domain_id' => $this->_domainID2,
351 'return' => 'uniq_email_per_site',
6a488035 352 );
6a488035 353 $description = "shows get setting a variable for a given domain - if no domain is set current is assumed";
7fbb4198 354
355 $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__);
6a488035
TO
356
357 $params = array(
6a488035
TO
358 'return' => 'uniq_email_per_site',
359 );
6a488035 360 $description = "shows getting a variable for a current domain";
7fbb4198 361 $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__, $description, 'GetSettingCurrentDomain');
6a488035
TO
362 $this->assertArrayHasKey(CRM_Core_Config::domainID(), $result['values']);
363 }
364/**
365 * setting api should set & fetch settings stored in config as well as those in settings table
366 */
367 function testSetConfigSetting() {
368 $config = CRM_Core_Config::singleton();
369 $this->assertFalse($config->debug == 1);
7fbb4198 370 $params = array(
6a488035
TO
371 'domain_id' => $this->_domainID2,
372 'debug_enabled' => 1,
373 );
7fbb4198 374 $result = $this->callAPISuccess('setting', 'create', $params);
5b887f26 375 CRM_Core_BAO_Domain::setDomain($this->_domainID2);
376 $config = CRM_Core_Config::singleton(TRUE, TRUE);
377 CRM_Core_BAO_Domain::resetDomain();
6a488035
TO
378 $this->assertTrue($config->debug == 1);
379 // this should NOT be stored in the settings table now - only in config
380 $sql = " SELECT count(*) as c FROM civicrm_setting WHERE name LIKE '%debug%'";
381 $dao = CRM_Core_DAO::executeQuery($sql);
382 $dao->fetch();
383 $this->assertEquals($dao->c, 0);
384 }
385 /**
386 * setting api should set & fetch settings stored in config as well as those in settings table
387 */
388 function testGetConfigSetting() {
7fbb4198 389 $settings = $this->callAPISuccess('setting', 'get', array(
390 'name' => 'defaultCurrency', 'sequential' => 1,)
6a488035 391 );
6a488035
TO
392 $this->assertEquals('USD', $settings['values'][0]['defaultCurrency']);
393 }
2ba45310 394
395 /**
396 * setting api should set & fetch settings stored in config as well as those in settings table
397 */
398 function testGetSetConfigSettingMultipleDomains() {
7fbb4198 399 $settings = $this->callAPISuccess('setting', 'create', array(
400 'defaultCurrency' => 'USD', 'domain_id' => $this->_currentDomain)
2ba45310 401 );
7fbb4198 402 $settings = $this->callAPISuccess('setting', 'create', array(
403 'defaultCurrency' => 'CAD', 'domain_id' => $this->_domainID2)
2ba45310 404 );
7fbb4198 405 $settings = $this->callAPISuccess('setting', 'get', array(
406 'return' => 'defaultCurrency', 'domain_id' => 'all',
2ba45310 407 )
408 );
409 $this->assertEquals('USD', $settings['values'][$this->_currentDomain]['defaultCurrency']);
410 $this->assertEquals('CAD', $settings['values'][$this->_domainID2]['defaultCurrency'],
411 "second domain (id {$this->_domainID2} ) should be set to CAD. First dom was {$this->_currentDomain} & was USD");
412
413 }
414
6a488035
TO
415/*
416 * Use getValue against a config setting
417 */
418 function testGetValueConfigSetting() {
7fbb4198 419 $params = array( 'name' => 'monetaryThousandSeparator',
6a488035
TO
420 'group' => 'Localization Setting',
421 );
7fbb4198 422 $result = $this->callAPISuccess('setting', 'getvalue', $params);
6a488035
TO
423 $this->assertEquals(',', $result);
424 }
425
426 function testGetValue() {
7fbb4198 427 $params = array( 'name' => 'petition_contacts',
6a488035
TO
428 'group' => 'Campaign Preferences'
429 );
6a488035 430 $description = "Demonstrates getvalue action - intended for runtime use as better caching than get";
7fbb4198 431
432 $result = $this->callAPIAndDocument('setting', 'getvalue', $params, __FUNCTION__, __FILE__, $description);
433 $this->assertEquals('Petition Contacts', $result);
6a488035
TO
434 }
435
436 function testGetDefaults() {
7fbb4198 437 $description = "gets defaults setting a variable for a given domain - if no domain is set current is assumed";
6a488035 438
7fbb4198 439 $params = array(
6a488035
TO
440 'name' => 'address_format',
441 );
7fbb4198 442 $result = $this->callAPIAndDocument('setting', 'getdefaults', $params, __FUNCTION__, __FILE__,$description,'GetDefaults','getdefaults');
6a488035 443 $this->assertEquals("{contact.address_name}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}", $result['values'][CRM_Core_Config::domainID()]['address_format']);
7fbb4198 444 $params = array('name' => 'mailing_format',);
445 $result = $this->callAPISuccess('setting', 'getdefaults', $params);
6a488035
TO
446 $this->assertEquals("{contact.addressee}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}", $result['values'][CRM_Core_Config::domainID()]['mailing_format']);
447 $this->assertArrayHasKey(CRM_Core_Config::domainID(), $result['values']);
448 }
449 /*
450 * Function tests reverting a specific parameter
451 */
452 function testRevert() {
453
7fbb4198 454 $params = array( 'address_format' => 'xyz',
6a488035
TO
455 'mailing_format' => 'bcs',
456 );
7fbb4198 457 $result = $this->callAPISuccess('setting', 'create', $params);
6a488035 458 $this->assertAPISuccess($result, "in line " . __LINE__);
7fbb4198 459 $revertParams = array( 'name' => 'address_format'
6a488035 460 );
7fbb4198 461 $result = $this->callAPISuccess('setting', 'get', $params);
6a488035
TO
462 //make sure it's set
463 $this->assertEquals('xyz', $result['values'][CRM_Core_Config::domainID()]['address_format']);
464 $description = "Demonstrates reverting a parameter to default value";
7fbb4198 465 $result = $this->callAPIAndDocument('setting', 'revert', $revertParams, __FUNCTION__, __FILE__,$description,'','revert');
6a488035 466 //make sure it's reverted
7fbb4198 467 $result = $this->callAPISuccess('setting', 'get', $params);
6a488035 468 $this->assertEquals("{contact.address_name}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}", $result['values'][CRM_Core_Config::domainID()]['address_format']);
7fbb4198 469 $params = array( 'return' => array('mailing_format'),
6a488035 470 );
7fbb4198 471 $result = $this->callAPISuccess('setting', 'get', $params);
6a488035
TO
472 //make sure it's unchanged
473 $this->assertEquals('bcs', $result['values'][CRM_Core_Config::domainID()]['mailing_format']);
474 }
475 /*
476 * Tests reverting ALL parameters (specific domain)
477 */
478 function testRevertAll() {
479
7fbb4198 480 $params = array( 'address_format' => 'xyz',
6a488035
TO
481 'mailing_format' => 'bcs',
482 );
7fbb4198 483 $result = $this->callAPISuccess('setting', 'create', $params);
484 $revertParams = array( );
485 $result = $this->callAPISuccess('setting', 'get', $params);
6a488035
TO
486 //make sure it's set
487 $this->assertEquals('xyz', $result['values'][CRM_Core_Config::domainID()]['address_format']);
488
7fbb4198 489 $this->callAPISuccess('setting', 'revert', $revertParams);
6a488035 490 //make sure it's reverted
7fbb4198 491 $result = $this->callAPISuccess('setting', 'get', array('group' => 'core'));
6a488035
TO
492 $this->assertEquals("{contact.address_name}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}", $result['values'][CRM_Core_Config::domainID()]['address_format']);
493 $this->assertEquals("{contact.addressee}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}", $result['values'][CRM_Core_Config::domainID()]['mailing_format']);
494 }
495
496 /*
497 * Tests filling missing params
498 */
499 function testFill() {
500 $domparams = array(
501 'name' => 'B Team Domain',
7fbb4198 502 );
503 $dom = $this->callAPISuccess('domain', 'create', $domparams);
504 $params = array( 'domain_id' => 'all',
6a488035 505 );
7fbb4198 506 $result = $this->callAPISuccess('setting', 'get', $params);
507 $params = array( 'address_format' => 'xyz',
6a488035
TO
508 'mailing_format' => 'bcs',
509 'domain_id' => $this->_domainID2,
510 );
7fbb4198 511 $result = $this->callAPISuccess('setting', 'create', $params);
512 $params = array( 'domain_id' => $dom['id'],
6a488035 513 );
7fbb4198 514 $result = $this->callAPISuccess('setting', 'get', $params);
6a488035
TO
515 $this->assertAPISuccess($result, "in line " . __LINE__);
516 $this->assertArrayNotHasKey('tag_unconfirmed', $result['values'][$dom['id']],'setting for domain 3 should not be set. Debug this IF domain test is passing');
7fbb4198 517 $result = $this->callAPISuccess('setting', 'fill', $params);
6a488035 518 $this->assertAPISuccess($result, "in line " . __LINE__);
7fbb4198 519 $result = $this->callAPISuccess('setting', 'get', $params);
6a488035
TO
520 $this->assertAPISuccess($result, "in line " . __LINE__);
521 $this->assertArrayHasKey('tag_unconfirmed', $result['values'][$dom['id']]);
f64cd471 522 $this->assertArrayHasKey('extensionsDir', $result['values'][$dom['id']]);
6a488035
TO
523 $this->assertEquals('Unconfirmed', $result['values'][$dom['id']]['tag_unconfirmed']);
524 }
525}
526