From 00f559e853696358fd135994ed1f749650cbdbdc Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 8 Nov 2022 12:44:49 +1300 Subject: [PATCH] Add County api & fix test to use it The previous test was failing due to cached values not being cleared by the sql insert --- CRM/Core/BAO/County.php | 35 +++++++++++++++++++ Civi/Api4/County.php | 22 ++++++++++++ ...dual_country_state_county_with_related.csv | 16 ++++----- .../CRM/Contact/Import/Parser/ContactTest.php | 10 ++++-- 4 files changed, 72 insertions(+), 11 deletions(-) create mode 100644 CRM/Core/BAO/County.php create mode 100644 Civi/Api4/County.php diff --git a/CRM/Core/BAO/County.php b/CRM/Core/BAO/County.php new file mode 100644 index 0000000000..099aa1e0e2 --- /dev/null +++ b/CRM/Core/BAO/County.php @@ -0,0 +1,35 @@ +setValues([ + 'name' => 'Farnell', + 'abbreviation' => '', + 'state_province_id' => 1640, + ])->execute()->first()['id']; $childKey = $this->getRelationships()['Child of']['id'] . '_a_b'; $addressCustomGroupID = $this->createCustomGroup(['extends' => 'Address', 'name' => 'Address']); $contactCustomGroupID = $this->createCustomGroup(['extends' => 'Contact', 'name' => 'Contact']); @@ -1340,7 +1344,7 @@ class CRM_Contact_Import_Parser_ContactTest extends CiviUnitTestCase { $this->importCSV($csv, $mapper); $contacts = $this->getImportedContacts(); foreach ($contacts as $contact) { - $this->assertEquals(999, $contact['address'][0]['county_id']); + $this->assertEquals($countyID, $contact['address'][0]['county_id']); $this->assertEquals(1013, $contact['address'][0]['country_id']); $this->assertEquals(1640, $contact['address'][0]['state_province_id']); } -- 2.25.1