From ab9aa379f7d8682dd86dc6e7720a869eb783be70 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 3 Jun 2013 16:08:10 -0700 Subject: [PATCH] Fix creating test objects CRM-12464 ---------------------------------------- * CRM-12464: Add PseudoConstants to Schema Metadata http://issues.civicrm.org/jira/browse/CRM-12464 --- CRM/Core/DAO.php | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index f37b8d3e16..697a671fa8 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -1275,12 +1275,10 @@ SELECT contact_id 'CRM_Core_DAO_Domain', ); - require_once (str_replace('_', DIRECTORY_SEPARATOR, $daoName) . ".php"); - for ($i = 0; $i < $numObjects; ++$i) { ++$counter; - $object = new $daoName ( ); + $object = new $daoName(); $fields = &$object->fields(); foreach ($fields as $name => $value) { @@ -1323,24 +1321,13 @@ SELECT contact_id continue; } - $constant = CRM_Utils_Array::value('pseudoconstant', $value); - if (!empty($constant)) { - if (empty($constant['name'])) { - throw new CRM_Core_Exception("Failed to choose value for $daoName ($name) -- missing pseudo-constant name"); - } - $constantValues = CRM_Utils_PseudoConstant::getConstant($constant['name']); - if (!empty($constantValues)) { - $constantOptions = array_keys($constantValues); - $object->$dbName = $constantOptions[0]; - } - continue; - } - $enum = CRM_Utils_Array::value('enumValues', $value); - if (!empty($enum)) { - $options = explode(',', $enum); - $object->$dbName = $options[0]; + // Pick an option value if needed + $options = $daoName::buildOptions($dbName); + if ($options) { + $object->$dbName = key($options); continue; } + switch ($value['type']) { case CRM_Utils_Type::T_INT: case CRM_Utils_Type::T_FLOAT: -- 2.25.1