Merge in 5.38
[civicrm-core.git] / tests / phpunit / CRM / Contact / BAO / QueryStateNameTest.php
1 <?php
2
3 /**
4 * Class CRM_Contact_BAO_QueryStateNameTest
5 * @group headless
6 */
7 class CRM_Contact_BAO_QueryStateNameTest extends CiviUnitTestCase {
8
9 /**
10 * Test case for state_province_name pseudofield
11 *
12 * See CRM-15505: Mailing labels show the state/province name as the abbreviation rather than the full state/province name
13 * Change to CRM_Contact_BAO_query::convertToPseudoNames()
14 */
15 public function testStateName() {
16 $state_name = 'Norfolk';
17 $state_abbreviation = 'NFK';
18 $create_params = [
19 'contact_type' => 'Individual',
20 'first_name' => 'John',
21 'last_name' => 'Doe',
22 'api.Address.create' => [
23 'location_type_id' => 'Home',
24 'state_province_id' => $state_name,
25 ],
26 ];
27 $create_res = civicrm_api3('Contact', 'Create', $create_params);
28
29 $get_params = [
30 'id' => $create_res['id'],
31 'sequential' => 1,
32 ];
33 $get_res = civicrm_api3('Contact', 'get', $get_params);
34 $this->assertEquals($state_name, $get_res['values'][0]['state_province_name']);
35 // Lock in that state_provice should equal that of the abbreviation.
36 $this->assertEquals($state_abbreviation, $get_res['values'][0]['state_province']);
37 }
38
39 }