From: Tim Otten Date: Fri, 22 Aug 2014 08:05:49 +0000 (-0700) Subject: CRM_Core_DAO - Cleanup in createTestObject X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f290b6ef6f340c72cf8a52f7b817f477864c6451;p=civicrm-core.git CRM_Core_DAO - Cleanup in createTestObject --- diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 7e4a6e930c..28948d83e6 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1516,40 +1516,44 @@ SELECT contact_id /** @var CRM_Core_DAO $object */ $object = new $daoName(); - $fields = &$object->fields(); + $fields = & $object->fields(); foreach ($fields as $fieldName => $fieldDef) { $dbName = $fieldDef['name']; + $FKClassName = CRM_Utils_Array::value('FKClassName', $fieldDef); $required = CRM_Utils_Array::value('required', $fieldDef); + if (CRM_Utils_Array::value($dbName, $params) !== NULL && !is_array($params[$dbName])) { $object->$dbName = $params[$dbName]; } elseif ($dbName != 'id') { - if (CRM_Utils_Array::value('FKClassName', $fieldDef) != NULL) { + if ($FKClassName != NULL) { $object->assignTestFK($fieldName, $fieldDef, $params); continue; + } else { + $object->assignTestValue($fieldName, $fieldDef, $counter); } - - $object->assignTestValue($fieldName, $fieldDef, $counter); } } $object->save(); if (!$createOnly) { - $objects[$i] = $object; - } - else unset($object); + else { + unset($object); + } } if ($createOnly) { - return; - } - elseif ($numObjects == 1) { return $objects[0];} - else return $objects; + elseif ($numObjects == 1) { + return $objects[0]; + } + else { + return $objects; + } } /**