From dc634652d623a07d98e2da72eaf4657723099960 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 9 Feb 2023 22:52:27 -0800 Subject: [PATCH] (NFC) ContactJoinTest - Ensure that ambiguous state is matched to country Before: There is one test using 'AK' -- in the US. After: There are two tests using 'AK -- in the US and in Nigeria. --- .../phpunit/api/v4/Entity/ContactJoinTest.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/phpunit/api/v4/Entity/ContactJoinTest.php b/tests/phpunit/api/v4/Entity/ContactJoinTest.php index 9f7d026e12..f68ae8c7f2 100644 --- a/tests/phpunit/api/v4/Entity/ContactJoinTest.php +++ b/tests/phpunit/api/v4/Entity/ContactJoinTest.php @@ -117,6 +117,7 @@ class ContactJoinTest extends Api4TestBase { ->execute(); $this->assertCount(1, $addr); $this->assertEquals('Hello', $contact['address_billing.city']); + $this->assertEquals(1001, $contact['address_billing.state_province_id']); $this->assertEquals(1228, $contact['address_billing.country_id']); $emails = Email::get(FALSE) ->addWhere('contact_id', '=', $contact['id']) @@ -126,6 +127,33 @@ class ContactJoinTest extends Api4TestBase { $this->assertEquals('b@test.com', $contact['email_billing.email']); } + /** + * This is the same as testCreateWithPrimaryAndBilling, but the ambiguous + * state "AK" is resolved within a different country "NG". + */ + public function testCreateWithPrimaryAndBilling_Nigeria() { + $contact = $this->createTestRecord('Contact', [ + 'email_primary.email' => 'a@test.com', + 'email_billing.email' => 'b@test.com', + 'address_billing.city' => 'Hello', + 'address_billing.state_province_id:abbr' => 'AK', + 'address_billing.country_id:abbr' => 'NG', + ]); + $addr = Address::get(FALSE) + ->addWhere('contact_id', '=', $contact['id']) + ->execute(); + $this->assertCount(1, $addr); + $this->assertEquals('Hello', $contact['address_billing.city']); + $this->assertEquals(3885, $contact['address_billing.state_province_id']); + $this->assertEquals(1157, $contact['address_billing.country_id']); + $emails = Email::get(FALSE) + ->addWhere('contact_id', '=', $contact['id']) + ->execute(); + $this->assertCount(2, $emails); + $this->assertEquals('a@test.com', $contact['email_primary.email']); + $this->assertEquals('b@test.com', $contact['email_billing.email']); + } + public function testUpdateDeletePrimaryAndBilling() { $contact = $this->createTestRecord('Contact', [ 'phone_primary.phone' => '12345', -- 2.25.1