From 9091882fbae776d8b5ff16841e749d37c1eab486 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 17 Aug 2022 08:34:18 +1200 Subject: [PATCH] Remove function only called from unittest --- CRM/Import/Parser.php | 56 ------------------- .../CRM/Contact/Import/Parser/ContactTest.php | 18 ------ 2 files changed, 74 deletions(-) diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index 5574ce39f9..ab500184c5 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -1915,62 +1915,6 @@ abstract class CRM_Import_Parser implements UserJobInterface { return TRUE; } - /** - * Check if an error in custom data. - * - * @deprecated all of this is duplicated if getTransformedValue is used. - * - * @param array $params - * @param string $errorMessage - * A string containing all the error-fields. - * - * @param null $csType - */ - public function isErrorInCustomData($params, &$errorMessage, $csType = NULL) { - $dateType = CRM_Core_Session::singleton()->get("dateTypes"); - $errors = []; - - if (!empty($params['contact_sub_type'])) { - $csType = $params['contact_sub_type'] ?? NULL; - } - - if (empty($params['contact_type'])) { - $params['contact_type'] = 'Individual'; - } - - // get array of subtypes - CRM-18708 - if (in_array($csType, CRM_Contact_BAO_ContactType::basicTypes(TRUE), TRUE)) { - $csType = $this->getSubtypes($params['contact_type']); - } - - if (is_array($csType)) { - // fetch custom fields for every subtype and add it to $customFields array - // CRM-18708 - $customFields = []; - foreach ($csType as $cType) { - $customFields += CRM_Core_BAO_CustomField::getFields($params['contact_type'], FALSE, FALSE, $cType); - } - } - else { - $customFields = CRM_Core_BAO_CustomField::getFields($params['contact_type'], FALSE, FALSE, $csType); - } - - foreach ($params as $key => $value) { - if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) { - //For address custom fields, we do get actual custom field value as an inner array of - //values so need to modify - if (!array_key_exists($customFieldID, $customFields)) { - return ts('field ID'); - } - /* check if it's a valid custom field id */ - $errors[] = $this->validateCustomField($customFieldID, $value, $customFields[$customFieldID], $dateType); - } - } - if ($errors) { - $errorMessage .= ($errorMessage ? '; ' : '') . implode('; ', array_filter($errors)); - } - } - /** * get subtypes given the contact type * diff --git a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php index 17de9e8ebb..2efd3dae00 100644 --- a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php +++ b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php @@ -973,24 +973,6 @@ class CRM_Contact_Import_Parser_ContactTest extends CiviUnitTestCase { $this->callAPISuccessGetSingle('Contact', $contactValues); } - /** - * Test the determination of whether a custom field is valid. - */ - public function testCustomFieldValidation(): void { - $errorMessage = ''; - $customGroup = $this->customGroupCreate([ - 'extends' => 'Contact', - 'title' => 'ABC', - ]); - $customField = $this->customFieldOptionValueCreate($customGroup, 'fieldABC', ['html_type' => 'Select', 'serialize' => 1]); - $params = [ - 'custom_' . $customField['id'] => 'Label1|Label2', - ]; - $parser = new CRM_Contact_Import_Parser_Contact(); - $parser->isErrorInCustomData($params, $errorMessage); - $this->assertEquals(NULL, $errorMessage); - } - /** * Test the import validation. * -- 2.25.1