From 6a03ea43c78cd6ba4873834858896aabbeba2a57 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 28 Sep 2015 20:22:33 -0400 Subject: [PATCH] Fix test failures --- CRM/Utils/Type.php | 6 +++--- tests/phpunit/CRM/Utils/TypeTest.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CRM/Utils/Type.php b/CRM/Utils/Type.php index 50e3b38d31..81efac86b0 100644 --- a/CRM/Utils/Type.php +++ b/CRM/Utils/Type.php @@ -173,13 +173,13 @@ class CRM_Utils_Type { // CRM-8925 for custom fields of this type case 'Country': case 'StateProvince': - if (is_array($data)) { + // Handle multivalued data in delimited or array format + if (is_array($data) || (strpos($data, CRM_Core_DAO::VALUE_SEPARATOR) !== FALSE)) { $valid = TRUE; - foreach ($data as &$item) { + foreach (CRM_Utils_Array::explodePadded($data) as $item) { if (!CRM_Utils_Rule::positiveInteger($item)) { $valid = FALSE; } - $item = (int) $item; } if ($valid) { return $data; diff --git a/tests/phpunit/CRM/Utils/TypeTest.php b/tests/phpunit/CRM/Utils/TypeTest.php index eef34932af..e9235565cc 100644 --- a/tests/phpunit/CRM/Utils/TypeTest.php +++ b/tests/phpunit/CRM/Utils/TypeTest.php @@ -68,7 +68,7 @@ class CRM_Utils_TypeTest extends CiviUnitTestCase { array(-10, 'Positive', NULL), array('-10', 'Positive', NULL), array('-10foo', 'Positive', NULL), - array(array('10', 20), 'Country', array(10, 20)), + array(array('10', 20), 'Country', array('10', 20)), array(array('10', '-10foo'), 'Country', NULL), array('', 'Timestamp', ''), array('', 'ContactReference', ''), -- 2.25.1