Skip to content
Snippets Groups Projects
Commit ab9aa379 authored by colemanw's avatar colemanw
Browse files

Fix creating test objects CRM-12464

----------------------------------------
* CRM-12464: Add PseudoConstants to Schema Metadata
  http://issues.civicrm.org/jira/browse/CRM-12464
parent deceed83
Branches
Tags
No related merge requests found
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment