Merge pull request #15676 from artfulrobot/handle-exceptions-from-payment-processors
[civicrm-core.git] / tests / phpunit / CRM / Contact / BAO / QueryStateNameTest.php
CommitLineData
144d0efe
AS
1<?php
2
3/**
4 * Class CRM_Contact_BAO_QueryStateNameTest
5 * @group headless
6 */
7class 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';
949cb2d0 17 $state_abbreviation = 'NFK';
9099cab3 18 $create_params = [
144d0efe
AS
19 'contact_type' => 'Individual',
20 'first_name' => 'John',
21 'last_name' => 'Doe',
9099cab3 22 'api.Address.create' => [
144d0efe
AS
23 'location_type_id' => 'Home',
24 'state_province_id' => $state_name,
9099cab3
CW
25 ],
26 ];
144d0efe
AS
27 $create_res = civicrm_api3('Contact', 'Create', $create_params);
28
9099cab3 29 $get_params = [
144d0efe
AS
30 'id' => $create_res['id'],
31 'sequential' => 1,
9099cab3 32 ];
144d0efe 33 $get_res = civicrm_api3('Contact', 'get', $get_params);
144d0efe 34 $this->assertEquals($state_name, $get_res['values'][0]['state_province_name']);
949cb2d0
SL
35 // Lock in that state_provice should equal that of the abbreviation.
36 $this->assertEquals($state_abbreviation, $get_res['values'][0]['state_province']);
144d0efe
AS
37 }
38
39}