Skip to content
Snippets Groups Projects
Unverified Commit fe4a5e89 authored by eileen's avatar eileen :8ball: Committed by GitHub
Browse files

Merge pull request #13176 from aydun/flatten_fix

Flatten fix
parents 44f8a932 ca80e7e9
Branches
Tags
No related merge requests found
......@@ -125,6 +125,8 @@ class CRM_Dedupe_Finder {
if (!$params) {
return array();
}
// This may no longer be required - see https://github.com/civicrm/civicrm-core/pull/13176
$params = array_filter($params);
$foundByID = FALSE;
if ($ruleGroupID) {
......
......@@ -238,9 +238,7 @@ class CRM_Utils_Array {
self::flatten($value, $flat, $newPrefix, $seperator);
}
else {
if (!empty($value)) {
$flat[$newPrefix] = $value;
}
$flat[$newPrefix] = $value;
}
}
}
......
......@@ -328,4 +328,43 @@ class CRM_Utils_ArrayTest extends CiviUnitTestCase {
$this->assertEquals($expected, $source);
}
/**
* Test the flatten function
*/
public function testFlatten() {
$data = [
'my_array' => [
'0' => 'bar',
'1' => 'baz',
'2' => 'boz',
],
'my_complex' => [
'dog' => 'woof',
'asdf' => [
'my_zero' => 0,
'my_int' => 1,
'my_null' => NULL,
'my_empty' => '',
],
],
'my_simple' => 999,
];
$expected = [
'my_array.0' => 'bar',
'my_array.1' => 'baz',
'my_array.2' => 'boz',
'my_complex.dog' => 'woof',
'my_complex.asdf.my_zero' => 0,
'my_complex.asdf.my_int' => 1,
'my_complex.asdf.my_null' => NULL,
'my_complex.asdf.my_empty' => '',
'my_simple' => 999,
];
$flat = [];
CRM_Utils_Array::flatten($data, $flat);
$this->assertEquals($flat, $expected);
}
}
......@@ -156,6 +156,7 @@ class WhitelistSubscriberTest extends \CiviUnitTestCase {
'id' => 2,
'title' => 'second widget',
'api.Sprocket.get' => array(
'is_error' => 0,
'count' => 2,
'version' => 3,
'values' => array(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment