Merge pull request #14919 from eileenmcnaughton/mem_review
[civicrm-core.git] / tests / phpunit / api / v3 / AddressTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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
28 /**
29 * Test APIv3 civicrm_activity_* functions
30 *
31 * @package CiviCRM_APIv3
32 * @subpackage API_Contact
33 */
34
35 /**
36 * Class api_v3_AddressTest
37 * @group headless
38 */
39 class api_v3_AddressTest extends CiviUnitTestCase {
40 protected $_contactID;
41 protected $_locationType;
42 protected $_params;
43
44 protected $_entity;
45
46 public function setUp() {
47 $this->_entity = 'Address';
48 parent::setUp();
49
50 $this->_contactID = $this->organizationCreate();
51 $this->_locationType = $this->locationTypeCreate();
52 CRM_Core_PseudoConstant::flush();
53
54 $this->_params = [
55 'contact_id' => $this->_contactID,
56 'location_type_id' => $this->_locationType->id,
57 'street_name' => 'Ambachtstraat',
58 'street_number' => '23',
59 'street_address' => 'Ambachtstraat 23',
60 'postal_code' => '6971 BN',
61 'country_id' => '1152',
62 'city' => 'Brummen',
63 'is_primary' => 1,
64 ];
65 }
66
67 public function tearDown() {
68 $this->locationTypeDelete($this->_locationType->id);
69 $this->contactDelete($this->_contactID);
70 $this->quickCleanup(['civicrm_address', 'civicrm_relationship']);
71 parent::tearDown();
72 }
73
74 /**
75 * @param int $version
76 * @dataProvider versionThreeAndFour
77 */
78 public function testCreateAddress($version) {
79 $this->_apiversion = $version;
80 $result = $this->callAPIAndDocument('address', 'create', $this->_params, __FUNCTION__, __FILE__);
81 $this->assertEquals(1, $result['count']);
82 $this->assertNotNull($result['values'][$result['id']]['id']);
83 $this->getAndCheck($this->_params, $result['id'], 'address');
84 }
85
86 /**
87 * @param int $version
88 * @dataProvider versionThreeAndFour
89 */
90 public function testCreateAddressParsing($version) {
91 $this->_apiversion = $version;
92 $params = [
93 'street_parsing' => 1,
94 'street_address' => '54A Excelsior Ave. Apt 1C',
95 'location_type_id' => $this->_locationType->id,
96 'contact_id' => $this->_contactID,
97 ];
98 $subfile = "AddressParse";
99 $description = "Demonstrates Use of address parsing param.";
100 $result = $this->callAPIAndDocument('address', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
101 $this->assertEquals(54, $result['values'][$result['id']]['street_number']);
102 $this->assertEquals('A', $result['values'][$result['id']]['street_number_suffix']);
103 $this->assertEquals('Excelsior Ave.', $result['values'][$result['id']]['street_name']);
104 $this->assertEquals('Apt 1C', $result['values'][$result['id']]['street_unit']);
105 $this->callAPISuccess('address', 'delete', ['id' => $result['id']]);
106
107 }
108
109 /**
110 * Is_primary should be set as a default.
111 * @param int $version
112 * @dataProvider versionThreeAndFour
113 */
114 public function testCreateAddressTestDefaults($version) {
115 $this->_apiversion = $version;
116 $params = $this->_params;
117 unset($params['is_primary']);
118 $result = $this->callAPISuccess('address', 'create', $params);
119 $this->assertEquals(1, $result['count']);
120 $this->assertEquals(1, $result['values'][$result['id']]['is_primary']);
121 $this->getAndCheck($this->_params, $result['id'], 'address');
122 }
123
124 /**
125 * If no location is specified when creating a new address, it should default to
126 * the LocationType default
127 *
128 * @param int $version
129 * @dataProvider versionThreeAndFour
130 */
131 public function testCreateAddressDefaultLocation($version) {
132 $this->_apiversion = $version;
133 $params = $this->_params;
134 unset($params['location_type_id']);
135 $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
136 $this->assertEquals(CRM_Core_BAO_LocationType::getDefault()->id, $result['values'][$result['id']]['location_type_id']);
137 $this->callAPISuccess($this->_entity, 'delete', ['id' => $result['id']]);
138 }
139
140 /**
141 * FIXME: Api4
142 */
143 public function testCreateAddressTooLongSuffix() {
144 $params = $this->_params;
145 $params['street_number_suffix'] = 'really long string';
146 $this->callAPIFailure('address', 'create', $params);
147 }
148
149 /**
150 * Create an address with a master ID and ensure that a relationship is created.
151 * @param int $version
152 * @dataProvider versionThreeAndFour
153 */
154 public function testCreateAddressWithMasterRelationshipHousehold($version) {
155 $this->_apiversion = $version;
156 $householdID = $this->householdCreate();
157 $address = $this->callAPISuccess('address', 'create', array_merge($this->_params, $this->_params, ['contact_id' => $householdID]));
158 $individualID = $this->individualCreate();
159 $individualParams = [
160 'contact_id' => $individualID,
161 'master_id' => $address['id'],
162 ];
163 $this->callAPISuccess('address', 'create', array_merge($this->_params, $individualParams));
164 $this->callAPISuccess('relationship', 'getcount', [
165 'contact_id_a' => $individualID,
166 'contact_id_b' => $this->_contactID,
167 ]);
168 }
169
170 /**
171 * Create an address with a master ID and ensure that a relationship is created.
172 * @param int $version
173 * @dataProvider versionThreeAndFour
174 */
175 public function testCreateAddressWithMasterRelationshipOrganization($version) {
176 $this->_apiversion = $version;
177 $address = $this->callAPISuccess('address', 'create', $this->_params);
178 $individualID = $this->individualCreate();
179 $individualParams = [
180 'contact_id' => $individualID,
181 'master_id' => $address['id'],
182 ];
183 $this->callAPISuccess('address', 'create', array_merge($this->_params, $individualParams));
184 $this->callAPISuccess('relationship', 'getcount', [
185 'contact_id_a' => $individualID,
186 'contact_id_b' => $this->_contactID,
187 ], 1);
188 }
189
190 /**
191 * Create an address with a master ID and relationship creation disabled.
192 * @param int $version
193 * @dataProvider versionThreeAndFour
194 */
195 public function testCreateAddressWithoutMasterRelationshipOrganization($version) {
196 $this->_apiversion = $version;
197 $address = $this->callAPISuccess('address', 'create', $this->_params);
198 $individualID = $this->individualCreate();
199 $individualParams = [
200 'contact_id' => $individualID,
201 'master_id' => $address['id'],
202 'update_current_employer' => 0,
203 ];
204 $this->callAPISuccess('address', 'create', array_merge($this->_params, $individualParams));
205 $this->callAPISuccess('relationship', 'getcount', [
206 'contact_id_a' => $individualID,
207 'contact_id_b' => $this->_contactID,
208 ], 0);
209 }
210
211 /**
212 * Create an address with a master ID and ensure that a relationship is created.
213 * @param int $version
214 * @dataProvider versionThreeAndFour
215 */
216 public function testCreateAddressWithMasterRelationshipChangingOrganization($version) {
217 $this->_apiversion = $version;
218 $address = $this->callAPISuccess('address', 'create', $this->_params);
219 $organisation2ID = $this->organizationCreate();
220 $address2 = $this->callAPISuccess('address', 'create', array_merge($this->_params, ['contact_id' => $organisation2ID]));
221 $individualID = $this->individualCreate();
222 $individualParams = array_merge($this->_params, [
223 'contact_id' => $individualID,
224 'master_id' => $address['id'],
225 ]);
226 $individualAddress = $this->callAPISuccess('address', 'create', $individualParams);
227 $individualParams['master_id'] = $address2['id'];
228 $individualParams['id'] = $individualAddress['id'];
229 $this->callAPISuccess('address', 'create', $individualParams);
230 $this->callAPISuccessGetCount('relationship', ['contact_id_a' => $individualID], 2);
231 $this->markTestIncomplete('Remainder of test checks that employer relationship is disabled when new one is created but turns out to be not happening - by design?');
232 $this->callAPISuccessGetCount('relationship', ['contact_id_a' => $individualID, 'is_active' => FALSE], 1);
233 $this->callAPISuccessGetCount('relationship', [
234 'contact_id_a' => $individualID,
235 'is_active' => TRUE,
236 'contact_id_b' => $organisation2ID,
237 ], 1);
238
239 }
240
241 /**
242 * Is_primary should be set as a default.
243 *
244 * ie. create the address, unset the params & recreate.
245 * is_primary should be 0 before & after the update. ie - having no other address
246 * is_primary is invalid.
247 * @param int $version
248 * @dataProvider versionThreeAndFour
249 */
250 public function testCreateAddressTestDefaultWithID($version) {
251 $this->_apiversion = $version;
252 $params = $this->_params;
253 $params['is_primary'] = 0;
254 $result = $this->callAPISuccess('address', 'create', $params);
255 unset($params['is_primary']);
256 $params['id'] = $result['id'];
257 $this->callAPISuccess('address', 'create', $params);
258 $result = $this->callAPISuccess('address', 'get', ['contact_id' => $params['contact_id']]);
259 $this->assertEquals(1, $result['count']);
260 $this->assertEquals(1, $result['values'][$result['id']]['is_primary']);
261 $this->getAndCheck($params, $result['id'], 'address', __FUNCTION__);
262 }
263
264 /**
265 * test address deletion.
266 * @param int $version
267 * @dataProvider versionThreeAndFour
268 */
269 public function testDeleteAddress($version) {
270 $this->_apiversion = $version;
271 //check there are no address to start with
272 $get = $this->callAPISuccess('address', 'get', [
273 'location_type_id' => $this->_locationType->id,
274 ]);
275 $this->assertEquals(0, $get['count'], 'Contact already exists ');
276
277 //create one
278 $create = $this->callAPISuccess('address', 'create', $this->_params);
279
280 $result = $this->callAPIAndDocument('address', 'delete', ['id' => $create['id']], __FUNCTION__, __FILE__);
281 $this->assertEquals(1, $result['count']);
282 $get = $this->callAPISuccess('address', 'get', [
283 'location_type_id' => $this->_locationType->id,
284 ]);
285 $this->assertEquals(0, $get['count'], 'Contact not successfully deleted In line ' . __LINE__);
286 }
287
288 /**
289 * Test civicrm_address_get - success expected.
290 * @param int $version
291 * @dataProvider versionThreeAndFour
292 */
293 public function testGetAddress($version) {
294 $this->_apiversion = $version;
295 $address = $this->callAPISuccess('address', 'create', $this->_params);
296
297 $params = [
298 'contact_id' => $this->_contactID,
299 'street_name' => $address['values'][$address['id']]['street_name'],
300 ];
301 $result = $this->callAPIAndDocument('Address', 'Get', $params, __FUNCTION__, __FILE__);
302 $this->callAPISuccess('Address', 'delete', ['id' => $result['id']]);
303 $this->assertEquals($address['values'][$address['id']]['location_type_id'], $result['values'][$address['id']]['location_type_id']);
304 $this->assertEquals($address['values'][$address['id']]['is_primary'], $result['values'][$address['id']]['is_primary']);
305 $this->assertEquals($address['values'][$address['id']]['street_address'], $result['values'][$address['id']]['street_address']);
306 }
307
308 /**
309 * Test civicrm_address_get - success expected.
310 * @param int $version
311 * @dataProvider versionThreeAndFour
312 */
313 public function testGetSingleAddress($version) {
314 $this->_apiversion = $version;
315 $this->callAPISuccess('address', 'create', $this->_params);
316 $params = [
317 'contact_id' => $this->_contactID,
318 ];
319 $address = $this->callAPISuccess('Address', 'getsingle', ($params));
320 $this->assertEquals($address['location_type_id'], $this->_params['location_type_id']);
321 $this->callAPISuccess('address', 'delete', ['id' => $address['id']]);
322 }
323
324 /**
325 * Test civicrm_address_get with sort option- success expected.
326 * @param int $version
327 * @dataProvider versionThreeAndFour
328 */
329 public function testGetAddressSort($version) {
330 $this->_apiversion = $version;
331 $create = $this->callAPISuccess('address', 'create', $this->_params);
332 $this->callAPISuccess('address', 'create', array_merge($this->_params, ['street_address' => 'yzy']));
333 $subfile = "AddressSort";
334 $description = "Demonstrates Use of sort filter.";
335 $params = [
336 'options' => [
337 'sort' => 'street_address DESC',
338 'limit' => 2,
339 ],
340 'sequential' => 1,
341 ];
342 $result = $this->callAPIAndDocument('Address', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile);
343 $this->assertEquals(2, $result['count']);
344 $this->assertEquals('Ambachtstraat 23', $result['values'][1]['street_address']);
345 $this->callAPISuccess('address', 'delete', ['id' => $create['id']]);
346 }
347
348 /**
349 * Test civicrm_address_get with sort option- success expected.
350 * @param int $version
351 * @dataProvider versionThreeAndFour
352 */
353 public function testGetAddressLikeSuccess($version) {
354 $this->_apiversion = $version;
355 $this->callAPISuccess('address', 'create', $this->_params);
356 $subfile = "AddressLike";
357 $description = "Demonstrates Use of Like.";
358 $params = [
359 'street_address' => ['LIKE' => '%mb%'],
360 'sequential' => 1,
361 ];
362 $result = $this->callAPIAndDocument('Address', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile);
363 $this->assertEquals(1, $result['count']);
364 $this->assertEquals('Ambachtstraat 23', $result['values'][0]['street_address']);
365 $this->callAPISuccess('address', 'delete', ['id' => $result['id']]);
366 }
367
368 /**
369 * Test civicrm_address_get with sort option- success expected.
370 * @param int $version
371 * @dataProvider versionThreeAndFour
372 */
373 public function testGetAddressLikeFail($version) {
374 $this->_apiversion = $version;
375 $create = $this->callAPISuccess('address', 'create', $this->_params);
376 $params = [
377 'street_address' => ['LIKE' => "'%xy%'"],
378 'sequential' => 1,
379 ];
380 $result = $this->callAPISuccess('Address', 'Get', ($params));
381 $this->assertEquals(0, $result['count']);
382 $this->callAPISuccess('address', 'delete', ['id' => $create['id']]);
383 }
384
385 /**
386 * FIXME: Api4 custom address fields broken?
387 */
388 public function testGetWithCustom() {
389 $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, __FILE__);
390
391 $params = $this->_params;
392 $params['custom_' . $ids['custom_field_id']] = "custom string";
393
394 $result = $this->callAPISuccess($this->_entity, 'create', $params);
395
396 $getParams = ['id' => $result['id'], 'return' => ['custom']];
397 $check = $this->callAPISuccess($this->_entity, 'get', $getParams);
398
399 $this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__);
400
401 $this->customFieldDelete($ids['custom_field_id']);
402 $this->customGroupDelete($ids['custom_group_id']);
403 $this->callAPISuccess('address', 'delete', ['id' => $result['id']]);
404 }
405
406 /**
407 * @param int $version
408 * @dataProvider versionThreeAndFour
409 */
410 public function testCreateAddressPrimaryHandlingChangeToPrimary($version) {
411 $this->_apiversion = $version;
412 $params = $this->_params;
413 unset($params['is_primary']);
414 $address1 = $this->callAPISuccess('address', 'create', $params);
415 $this->assertApiSuccess($address1);
416 //now we check & make sure it has been set to primary
417 $check = $this->callAPISuccess('address', 'getcount', [
418 'is_primary' => 1,
419 'id' => $address1['id'],
420 ]);
421 $this->assertEquals(1, $check);
422 $this->callAPISuccess('address', 'delete', ['id' => $address1['id']]);
423 }
424
425 /**
426 * @param int $version
427 * @dataProvider versionThreeAndFour
428 */
429 public function testCreateAddressPrimaryHandlingChangeExisting($version) {
430 $this->_apiversion = $version;
431 $address1 = $this->callAPISuccess('address', 'create', $this->_params);
432 $this->callAPISuccess('address', 'create', $this->_params);
433 $check = $this->callAPISuccess('address', 'getcount', [
434 'is_primary' => 1,
435 'contact_id' => $this->_contactID,
436 ]);
437 $this->assertEquals(1, $check);
438 $this->callAPISuccess('address', 'delete', ['id' => $address1['id']]);
439 }
440
441 /**
442 * Test Creating address of same type alreay ind the database
443 * This is legacy API v3 behaviour and not correct behaviour
444 * however we are too far down the path wiwth v3 to fix this
445 * @link https://chat.civicrm.org/civicrm/pl/zcq3jkg69jdt5g4aqze6bbe9pc
446 * FIXME: Api4
447 */
448 public function testCreateDuplicateLocationTypes() {
449 $address1 = $this->callAPISuccess('address', 'create', $this->_params);
450 $address2 = $this->callAPISuccess('address', 'create', [
451 'location_type_id' => $this->_locationType->id,
452 'street_address' => '1600 Pensilvania Avenue',
453 'city' => 'Washington DC',
454 'is_primary' => 0,
455 'is_billing' => 0,
456 'contact_id' => $this->_contactID,
457 ]);
458 $check = $this->callAPISuccess('address', 'getcount', [
459 'contact_id' => $this->_contactID,
460 'location_type_id' => $this->_locationType->id,
461 ]);
462 $this->assertEquals(2, $check);
463 $this->callAPISuccess('address', 'delete', ['id' => $address1['id']]);
464 $this->callAPISuccess('address', 'delete', ['id' => $address2['id']]);
465 }
466
467 public function testGetWithJoin() {
468 $cid = $this->individualCreate([
469 'api.Address.create' => [
470 'street_address' => __FUNCTION__,
471 'location_type_id' => $this->_locationType->id,
472 ],
473 ]);
474 $result = $this->callAPISuccess('address', 'getsingle', [
475 'check_permissions' => TRUE,
476 'contact_id' => $cid,
477 'street_address' => __FUNCTION__,
478 'return' => 'contact_id.contact_type',
479 ]);
480 $this->assertEquals('Individual', $result['contact_id.contact_type']);
481 }
482
483 /**
484 * Test Address create with a state name that at least two countries have, e.g. Maryland, United States vs. Maryland, Liberia
485 *
486 * @see https://lab.civicrm.org/dev/core/issues/725
487 */
488 public function testCreateAddressStateProvinceIDCorrectForCountry() {
489 $params = $this->_params;
490 $params['sequential'] = 1;
491 // United States country id
492 $params['country_id'] = '1228';
493 $params['state_province_id'] = 'Maryland';
494 $params['city'] = 'Baltimore';
495 $params['street_address'] = '600 N Charles St.';
496 $params['postal_code'] = '21201';
497 unset($params['street_name']);
498 unset($params['street_number']);
499 $address1 = $this->callAPISuccess('address', 'create', $params);
500 // should find state_province_id of 1019, Maryland, United States ... NOT 3497, Maryland, Liberia
501 $this->assertEquals('1019', $address1['values'][0]['state_province_id']);
502
503 // Now try it in Liberia
504 $params = $this->_params;
505 $params['sequential'] = 1;
506 // Liberia country id
507 $params['country_id'] = '1122';
508 $params['state_province_id'] = 'Maryland';
509 $address2 = $this->callAPISuccess('address', 'create', $params);
510 $this->assertEquals('3497', $address2['values'][0]['state_province_id']);
511 }
512
513 public function getSymbolicCountryStateExamples() {
514 return [
515 // [mixed $inputCountry, mixed $inputState, int $expectCountry, int $expectState]
516 [1228, 1004, 1228, 1004],
517 //['US', 'CA', 1228, 1004],
518 //['US', 'TX', 1228, 1042],
519 ['US', 'California', 1228, 1004],
520 [1228, 'Texas', 1228, 1042],
521 // Don't think these have been supported?
522 // ['United States', 1004, 1228, 1004] ,
523 // ['United States', 'TX', 1228, 1042],
524 ];
525 }
526
527 /**
528 * @param mixed $inputCountry
529 * Ex: 1228 or 'US'
530 * @param mixed $inputState
531 * Ex: 1004 or 'CA'
532 * @param int $expectCountry
533 * @param int $expectState
534 * @dataProvider getSymbolicCountryStateExamples
535 */
536 public function testCreateAddressSymbolicCountryAndState($inputCountry, $inputState, $expectCountry, $expectState) {
537 $cid = $this->individualCreate();
538 $r = $this->callAPISuccess('Address', 'create', [
539 'contact_id' => $cid,
540 'location_type_id' => 1,
541 'street_address' => '123 Some St',
542 'city' => 'Hereville',
543 //'US',
544 'country_id' => $inputCountry,
545 // 'California',
546 'state_province_id' => $inputState,
547 'postal_code' => '94100',
548 ]);
549 $created = CRM_Utils_Array::first($r['values']);
550 $this->assertEquals($expectCountry, $created['country_id']);
551 $this->assertEquals($expectState, $created['state_province_id']);
552 }
553
554 /**
555 * @param int $version
556 * @dataProvider versionThreeAndFour
557 */
558 public function testBuildStateProvinceOptionsWithDodgyProvinceLimit($version) {
559 $this->_apiversion = $version;
560 $provinceLimit = [1228, "abcd;ef"];
561 $this->callAPISuccess('setting', 'create', [
562 'provinceLimit' => $provinceLimit,
563 ]);
564 $result = $this->callAPIFailure('address', 'getoptions', ['field' => 'state_province_id']);
565 // confirm that we hit our error not a SQLI.
566 $this->assertEquals('Province limit or default country setting is incorrect', $result['error_message']);
567 $this->callAPISuccess('setting', 'create', [
568 'provinceLimit' => [1228],
569 ]);
570 // Now confirm with a correct province setting it works fine
571 $this->callAPISuccess('address', 'getoptions', ['field' => 'state_province_id']);
572 }
573
574 /**
575 * @param int $version
576 * @dataProvider versionThreeAndFour
577 */
578 public function testBuildCountryWithDodgyCountryLimitSetting($version) {
579 $this->_apiversion = $version;
580 $countryLimit = [1228, "abcd;ef"];
581 $this->callAPISuccess('setting', 'create', [
582 'countryLimit' => $countryLimit,
583 ]);
584 $result = $this->callAPIFailure('address', 'getoptions', ['field' => 'country_id']);
585 // confirm that we hit our error not a SQLI.
586 $this->assertEquals('Available Country setting is incorrect', $result['error_message']);
587 $this->callAPISuccess('setting', 'create', [
588 'countryLimit' => [1228],
589 ]);
590 // Now confirm with a correct province setting it works fine
591 $this->callAPISuccess('address', 'getoptions', ['field' => 'country_id']);
592 }
593
594 public function testBuildCountyWithDodgeStateProvinceFiltering() {
595 $result = $this->callAPIFailure('Address', 'getoptions', [
596 'field' => 'county_id',
597 'state_province_id' => "abcd;ef",
598 ]);
599 $this->assertEquals('Can only accept Integers for state_province_id filtering', $result['error_message']);
600 $goodResult = $this->callAPISuccess('Address', 'getoptions', [
601 'field' => 'county_id',
602 'state_province_id' => 1004,
603 ]);
604 $this->assertEquals('San Francisco', $goodResult['values'][4]);
605 }
606
607 public function testGetOptionsAbbr() {
608 $result = $this->callAPISuccess('Address', 'getoptions', [
609 'field' => 'country_id',
610 'context' => "abbreviate",
611 ]);
612 $this->assertContains('US', $result['values']);
613 $this->assertNotContains('United States', $result['values']);
614 $result = $this->callAPISuccess('Address', 'getoptions', [
615 'field' => 'state_province_id',
616 'context' => "abbreviate",
617 ]);
618 $this->assertContains('AL', $result['values']);
619 $this->assertNotContains('Alabama', $result['values']);
620 }
621
622 }