예제 #1
0
/**
 * write execution result to DB
 * 
 * @param resource &$db reference to database handler
 * @param obj &$exec_signature object with tproject_id,tplan_id,build_id,platform_id,user_id
 * 
 * @internal Revisions:
 * 
 *
 * 20100522 - BUGID 3479 - Bulk Execution - Custom Fields Bulk Assignment
 */
function write_execution(&$db, &$exec_signature, &$exec_data, $map_last_exec)
{
    $executions_table = DB_TABLE_PREFIX . 'executions';
    $resultsCfg = config_get('results');
    // $bugInterfaceOn = config_get('bugInterfaceOn');
    $db_now = $db->db_now();
    $cfield_mgr = new cfield_mgr($db);
    $cf_prefix = $cfield_mgr->get_name_prefix();
    $len_cfp = tlStringLen($cf_prefix);
    $cf_nodeid_pos = 4;
    $bulk_notes = '';
    $ENABLED = 1;
    $cf_map = $cfield_mgr->get_linked_cfields_at_execution($exec_signature->tproject_id, $ENABLED, 'testcase');
    $has_custom_fields = is_null($cf_map) ? 0 : 1;
    // extract custom fields id.
    $map_nodeid_array_cfnames = null;
    foreach ($exec_data as $input_name => $value) {
        if (strncmp($input_name, $cf_prefix, $len_cfp) == 0) {
            $dummy = explode('_', $input_name);
            $map_nodeid_array_cfnames[$dummy[$cf_nodeid_pos]][] = $input_name;
        }
    }
    if (isset($exec_data['do_bulk_save'])) {
        // create structure to use common algoritm
        $item2loop = $exec_data['status'];
        $is_bulk_save = 1;
        $bulk_notes = $db->prepare_string(trim($exec_data['bulk_exec_notes']));
    } else {
        $item2loop = $exec_data['save_results'];
        $is_bulk_save = 0;
    }
    foreach ($item2loop as $tcversion_id => $val) {
        $tcase_id = $exec_data['tc_version'][$tcversion_id];
        $current_status = $exec_data['status'][$tcversion_id];
        $version_number = $exec_data['version_number'][$tcversion_id];
        $has_been_executed = $current_status != $resultsCfg['status_code']['not_run'] ? TRUE : FALSE;
        if ($has_been_executed) {
            $my_notes = $is_bulk_save ? $bulk_notes : $db->prepare_string(trim($exec_data['notes'][$tcversion_id]));
            $sql = "INSERT INTO {$executions_table} " . "(build_id,tester_id,status,testplan_id,tcversion_id," . " execution_ts,notes,tcversion_number,platform_id)" . " VALUES ( {$exec_signature->build_id}, {$exec_signature->user_id}, '{$exec_data['status'][$tcversion_id]}'," . "{$exec_signature->tplan_id}, {$tcversion_id},{$db_now},'{$my_notes}'," . "{$version_number},{$exec_signature->platform_id}" . ")";
            $db->exec_query($sql);
            // at least for Postgres DBMS table name is needed.
            $execution_id = $db->insert_id($executions_table);
            if ($has_custom_fields) {
                // test useful when doing bulk update, because some type of custom fields
                // like checkbox can not exist on exec_data. => why ??
                //
                $hash_cf = null;
                $access_key = $is_bulk_save ? 0 : $tcase_id;
                if (isset($map_nodeid_array_cfnames[$access_key])) {
                    foreach ($map_nodeid_array_cfnames[$access_key] as $cf_v) {
                        $hash_cf[$cf_v] = $exec_data[$cf_v];
                    }
                }
                $cfield_mgr->execution_values_to_db($hash_cf, $tcversion_id, $execution_id, $exec_signature->tplan_id, $cf_map);
            }
        }
    }
}
예제 #2
0
function doUpdate(&$db, &$args, &$tcaseMgr, &$request)
{
    updateExecutionNotes($db, $args->exec_id, $args->notes);
    $cfield_mgr = new cfield_mgr($db);
    $cfield_mgr->execution_values_to_db($request, $args->tcversion_id, $args->exec_id, $args->tplan_id);
}
예제 #3
0
/**
 * write execution result to DB
 * 
 * @param resource &$db reference to database handler
 * @param obj &$exec_signature object with tproject_id,tplan_id,build_id,platform_id,user_id
 * 
 * @internal revisions
 * 
 */
function write_execution(&$db, &$exec_signature, &$exec_data, &$issueTracker)
{
    static $docRepo;
    if (is_null($docRepo)) {
        $docRepo = tlAttachmentRepository::create($db);
    }
    $executions_table = DB_TABLE_PREFIX . 'executions';
    $resultsCfg = config_get('results');
    $execCfg = config_get('exec_cfg');
    $db_now = $db->db_now();
    $cfield_mgr = new cfield_mgr($db);
    $cf_prefix = $cfield_mgr->get_name_prefix();
    $len_cfp = tlStringLen($cf_prefix);
    $cf_nodeid_pos = 4;
    $bulk_notes = '';
    $ENABLED = 1;
    $cf_map = $cfield_mgr->get_linked_cfields_at_execution($exec_signature->tproject_id, $ENABLED, 'testcase');
    $has_custom_fields = is_null($cf_map) ? 0 : 1;
    // extract custom fields id.
    $map_nodeid_array_cfnames = null;
    foreach ($exec_data as $input_name => $value) {
        if (strncmp($input_name, $cf_prefix, $len_cfp) == 0) {
            $dummy = explode('_', $input_name);
            $map_nodeid_array_cfnames[$dummy[$cf_nodeid_pos]][] = $input_name;
        }
    }
    if (isset($exec_data['do_bulk_save'])) {
        // create structure to use common algoritm
        $item2loop = $exec_data['status'];
        $is_bulk_save = 1;
        $bulk_notes = $db->prepare_string(trim($exec_data['bulk_exec_notes']));
        $execStatusKey = 'status';
    } else {
        $item2loop = $exec_data['save_results'];
        $is_bulk_save = 0;
        $execStatusKey = 'statusSingle';
    }
    $addIssueOp = array('createIssue' => null, 'issueForStep' => null);
    foreach ($item2loop as $tcversion_id => $val) {
        $tcase_id = $exec_data['tc_version'][$tcversion_id];
        $current_status = $exec_data[$execStatusKey][$tcversion_id];
        $version_number = $exec_data['version_number'][$tcversion_id];
        $has_been_executed = $current_status != $resultsCfg['status_code']['not_run'] ? TRUE : FALSE;
        if ($has_been_executed) {
            $my_notes = $is_bulk_save ? $bulk_notes : $db->prepare_string(trim($exec_data['notes'][$tcversion_id]));
            $sql = "INSERT INTO {$executions_table} " . "(build_id,tester_id,status,testplan_id,tcversion_id," . " execution_ts,notes,tcversion_number,platform_id,execution_duration)" . " VALUES ( {$exec_signature->build_id}, {$exec_signature->user_id}, '{$exec_data[$execStatusKey][$tcversion_id]}'," . "{$exec_signature->tplan_id}, {$tcversion_id},{$db_now},'{$my_notes}'," . "{$version_number},{$exec_signature->platform_id}";
            $dura = 'NULL ';
            if (isset($exec_data['execution_duration'])) {
                if (trim($exec_data['execution_duration']) == '') {
                    $dura = 'NULL ';
                } else {
                    $dura = floatval($exec_data['execution_duration']);
                }
            }
            $sql .= ',' . $dura . ")";
            $db->exec_query($sql);
            // at least for Postgres DBMS table name is needed.
            $execution_id = $db->insert_id($executions_table);
            $execSet[$tcversion_id] = $execution_id;
            if ($has_custom_fields) {
                // test useful when doing bulk update, because some type of custom fields
                // like checkbox can not exist on exec_data. => why ??
                //
                $hash_cf = null;
                $access_key = $is_bulk_save ? 0 : $tcase_id;
                if (isset($map_nodeid_array_cfnames[$access_key])) {
                    foreach ($map_nodeid_array_cfnames[$access_key] as $cf_v) {
                        $hash_cf[$cf_v] = $exec_data[$cf_v];
                    }
                }
                $cfield_mgr->execution_values_to_db($hash_cf, $tcversion_id, $execution_id, $exec_signature->tplan_id, $cf_map);
            }
            $hasMoreData = new stdClass();
            $hasMoreData->step_notes = isset($exec_data['step_notes']);
            $hasMoreData->step_status = isset($exec_data['step_status']);
            $hasMoreData->nike = $execCfg->steps_exec && ($hasMoreData->step_notes || $hasMoreData->step_status);
            if ($hasMoreData->nike) {
                $target = DB_TABLE_PREFIX . 'execution_tcsteps';
                $key2loop = array_keys($exec_data['step_notes']);
                foreach ($key2loop as $step_id) {
                    $doIt = !is_null($exec_data['step_notes'][$step_id]) && trim($exec_data['step_notes'][$step_id]) != '' || $exec_data['step_status'][$step_id] != $resultsCfg['status_code']['not_run'];
                    if ($doIt) {
                        $sql = " INSERT INTO {$target} (execution_id,tcstep_id,notes";
                        $values = " VALUES ( {$execution_id}, {$step_id}," . "'" . $db->prepare_string($exec_data['step_notes'][$step_id]) . "'";
                        $status = strtolower(trim($exec_data['step_status'][$step_id]));
                        $status = $status[0];
                        if ($status != $resultsCfg['status_code']['not_run']) {
                            $sql .= ",status";
                            $values .= ",'" . $db->prepare_string($status) . "'";
                        }
                        $sql .= ") " . $values . ")";
                        $db->exec_query($sql);
                        $execution_tcsteps_id = $db->insert_id($target);
                        // NOW MANAGE attachments
                        if (isset($_FILES['uploadedFile']['name'][$step_id]) && !is_null($_FILES['uploadedFile']['name'][$step_id])) {
                            $repOpt = array('allow_empty_title' => TRUE);
                            // May be we have enabled MULTIPLE on file upload
                            if (is_array($_FILES['uploadedFile']['name'][$step_id])) {
                                $curly = count($_FILES['uploadedFile']['name'][$step_id]);
                                for ($moe = 0; $moe < $curly; $moe++) {
                                    $fSize = isset($_FILES['uploadedFile']['size'][$step_id][$moe]) ? $_FILES['uploadedFile']['size'][$step_id][$moe] : 0;
                                    $fTmpName = isset($_FILES['uploadedFile']['tmp_name'][$step_id][$moe]) ? $_FILES['uploadedFile']['tmp_name'][$step_id][$moe] : '';
                                    if ($fSize && $fTmpName != "") {
                                        $fk2loop = array_keys($_FILES['uploadedFile']);
                                        foreach ($fk2loop as $tk) {
                                            $fInfo[$tk] = $_FILES['uploadedFile'][$tk][$step_id][$moe];
                                        }
                                        $uploaded = $docRepo->insertAttachment($execution_tcsteps_id, $target, '', $fInfo, $repOpt);
                                    }
                                }
                            } else {
                                $fSize = isset($_FILES['uploadedFile']['size'][$step_id]) ? $_FILES['uploadedFile']['size'][$step_id] : 0;
                                $fTmpName = isset($_FILES['uploadedFile']['tmp_name'][$step_id]) ? $_FILES['uploadedFile']['tmp_name'][$step_id] : '';
                                if ($fSize && $fTmpName != "") {
                                    $fk2loop = array_keys($_FILES['uploadedFile']);
                                    foreach ($fk2loop as $tk) {
                                        $fInfo[$tk] = $_FILES['uploadedFile'][$tk][$step_id];
                                    }
                                    $uploaded = $docRepo->insertAttachment($execution_tcsteps_id, $target, '', $fInfo);
                                }
                            }
                        }
                    }
                }
            }
            $itCheckOK = !is_null($issueTracker) && method_exists($issueTracker, 'addIssue');
            // re-init
            $addIssueOp = array('createIssue' => null, 'issueForStep' => null);
            if ($itCheckOK) {
                $execContext = new stdClass();
                $execContext->exec_id = $execution_id;
                $execContext->tcversion_id = $tcversion_id;
                $execContext->user = $exec_signature->user;
                $execContext->basehref = $exec_signature->basehref;
                $execContext->tplan_apikey = $exec_signature->tplan_apikey;
                // Issue on Test Case
                if (isset($exec_data['createIssue'])) {
                    completeCreateIssue($execContext, $exec_signature);
                    $addIssueOp['createIssue'] = addIssue($db, $execContext, $issueTracker);
                }
                // Issues at step level
                if (isset($exec_data['issueForStep'])) {
                    foreach ($exec_data['issueForStep'] as $stepID => $val) {
                        completeIssueForStep($execContext, $exec_signature, $exec_data, $stepID);
                        $addIssueOp['issueForStep'][$stepID] = addIssue($db, $execContext, $issueTracker, $stepID);
                    }
                }
            }
            // $itCheckOK
        }
    }
    return array($execSet, $addIssueOp);
}
예제 #4
0
/**
 * write execution result to DB
 * 
 * @param resource &$db reference to database handler
 * @param obj &$exec_signature object with tproject_id,tplan_id,build_id,platform_id,user_id
 * 
 * @internal revisions
 * 
 */
function write_execution(&$db, &$exec_signature, &$exec_data)
{
    $executions_table = DB_TABLE_PREFIX . 'executions';
    $resultsCfg = config_get('results');
    $execCfg = config_get('exec_cfg');
    $db_now = $db->db_now();
    $cfield_mgr = new cfield_mgr($db);
    $cf_prefix = $cfield_mgr->get_name_prefix();
    $len_cfp = tlStringLen($cf_prefix);
    $cf_nodeid_pos = 4;
    $bulk_notes = '';
    $ENABLED = 1;
    $cf_map = $cfield_mgr->get_linked_cfields_at_execution($exec_signature->tproject_id, $ENABLED, 'testcase');
    $has_custom_fields = is_null($cf_map) ? 0 : 1;
    // extract custom fields id.
    $map_nodeid_array_cfnames = null;
    foreach ($exec_data as $input_name => $value) {
        if (strncmp($input_name, $cf_prefix, $len_cfp) == 0) {
            $dummy = explode('_', $input_name);
            $map_nodeid_array_cfnames[$dummy[$cf_nodeid_pos]][] = $input_name;
        }
    }
    if (isset($exec_data['do_bulk_save'])) {
        // create structure to use common algoritm
        $item2loop = $exec_data['status'];
        $is_bulk_save = 1;
        $bulk_notes = $db->prepare_string(trim($exec_data['bulk_exec_notes']));
    } else {
        $item2loop = $exec_data['save_results'];
        $is_bulk_save = 0;
    }
    foreach ($item2loop as $tcversion_id => $val) {
        $tcase_id = $exec_data['tc_version'][$tcversion_id];
        $current_status = $exec_data['status'][$tcversion_id];
        $version_number = $exec_data['version_number'][$tcversion_id];
        $has_been_executed = $current_status != $resultsCfg['status_code']['not_run'] ? TRUE : FALSE;
        if ($has_been_executed) {
            $my_notes = $is_bulk_save ? $bulk_notes : $db->prepare_string(trim($exec_data['notes'][$tcversion_id]));
            $sql = "INSERT INTO {$executions_table} " . "(build_id,tester_id,status,testplan_id,tcversion_id," . " execution_ts,notes,tcversion_number,platform_id,execution_duration)" . " VALUES ( {$exec_signature->build_id}, {$exec_signature->user_id}, '{$exec_data['status'][$tcversion_id]}'," . "{$exec_signature->tplan_id}, {$tcversion_id},{$db_now},'{$my_notes}'," . "{$version_number},{$exec_signature->platform_id}";
            if (trim($exec_data['execution_duration']) == '') {
                $dura = 'NULL ';
            } else {
                $dura = floatval($exec_data['execution_duration']);
            }
            $sql .= ',' . $dura . ")";
            $db->exec_query($sql);
            // at least for Postgres DBMS table name is needed.
            $execution_id = $db->insert_id($executions_table);
            if ($has_custom_fields) {
                // test useful when doing bulk update, because some type of custom fields
                // like checkbox can not exist on exec_data. => why ??
                //
                $hash_cf = null;
                $access_key = $is_bulk_save ? 0 : $tcase_id;
                if (isset($map_nodeid_array_cfnames[$access_key])) {
                    foreach ($map_nodeid_array_cfnames[$access_key] as $cf_v) {
                        $hash_cf[$cf_v] = $exec_data[$cf_v];
                    }
                }
                $cfield_mgr->execution_values_to_db($hash_cf, $tcversion_id, $execution_id, $exec_signature->tplan_id, $cf_map);
            }
            // 20140412
            $hasMoreData = new stdClass();
            $hasMoreData->step_notes = isset($exec_data['step_notes']);
            $hasMoreData->step_status = isset($exec_data['step_status']);
            $hasMoreData->nike = $execCfg->steps_exec && ($hasMoreData->step_notes || $hasMoreData->step_status);
            if ($hasMoreData->nike) {
                $target = DB_TABLE_PREFIX . 'execution_tcsteps';
                $key2loop = array_keys($exec_data['step_notes']);
                foreach ($key2loop as $step_id) {
                    $doIt = !is_null($exec_data['step_notes'][$step_id]) && trim($exec_data['step_notes'][$step_id]) != '' || $exec_data['step_status'][$step_id] != $resultsCfg['status_code']['not_run'];
                    if ($doIt) {
                        $sql = " INSERT INTO {$target} (execution_id,tcstep_id,notes";
                        $values = " VALUES ( {$execution_id}, {$step_id}," . "'" . $db->prepare_string($exec_data['step_notes'][$step_id]) . "'";
                        $status = strtolower(trim($exec_data['step_status'][$step_id]));
                        $status = $status[0];
                        if ($status != $resultsCfg['status_code']['not_run']) {
                            $sql .= ",status";
                            $values .= ",'" . $db->prepare_string($status) . "'";
                        }
                        $sql .= ") " . $values . ")";
                        $db->exec_query($sql);
                    }
                }
            }
        }
    }
}
function saveImportedResultData(&$db, $resultData, $context, $options)
{
    if (!$resultData) {
        return;
    }
    $debugMsg = ' FUNCTION: ' . __FUNCTION__;
    $tables = tlObjectWithDB::getDBTables(array('executions', 'execution_bugs'));
    $tcaseCfg = config_get('testcase_cfg');
    // ---------------------------------------------------------------------------------------
    $l10n = array('import_results_tc_not_found' => '', 'import_results_invalid_result' => '', 'tproject_id_not_found' => '', 'import_results_ok' => '', 'invalid_cf' => '', 'import_results_skipped' => '');
    foreach ($l10n as $key => $value) {
        $l10n[$key] = lang_get($key);
    }
    $resultsCfg = config_get('results');
    foreach ($resultsCfg['status_label'] as $ks => $lbl) {
        $key = $resultsCfg['status_code'][$ks];
        $l10n[$key] = lang_get($lbl);
    }
    // ---------------------------------------------------------------------------------------
    // Get Column definitions to get size dinamically instead of create constants
    $columnDef = array();
    $adodbObj = $db->get_dbmgr_object();
    $columnDef['execution_bugs'] = $adodbObj->MetaColumns($tables['execution_bugs']);
    $keySet = array_keys($columnDef['execution_bugs']);
    foreach ($keySet as $keyName) {
        if (($keylow = strtolower($keyName)) != $keyName) {
            $columnDef['execution_bugs'][$keylow] = $columnDef['execution_bugs'][$keyName];
            unset($columnDef['execution_bugs'][$keyName]);
        }
    }
    $user = new tlUser($context->userID);
    $user->readFromDB($db);
    $tcase_mgr = new testcase($db);
    $resultMap = array();
    $tplan_mgr = null;
    $tc_qty = sizeof($resultData);
    if ($tc_qty) {
        $tplan_mgr = new testplan($db);
        $tproject_mgr = new testproject($db);
        $build_mgr = new build_mgr($db);
    }
    // Need to do checks on common settings
    //
    // test project exists
    //
    // test plan id:
    //              belongs to target test project
    //              is active
    // build id:
    //          belongs to target test plan
    //          is open
    //
    // platform id:
    //          is linked  to target test plan
    //
    // execution type if not present -> set to MANUAL
    //          if presente is valid i.e. inside the TL domain
    //
    $checks = array();
    $checks['status_ok'] = true;
    $checks['msg'] = null;
    $dummy = null;
    if (!is_null($context->tprojectID) && intval($context->tprojectID) > 0) {
        $dummy = array($tproject_mgr->get_by_id($context->tprojectID, array('output' => 'existsByID')));
    } else {
        if (!is_null($context->tprojectName)) {
            $dummy = $tproject_mgr->get_by_name($context->tprojectName, null, array('output' => 'existsByName'));
        }
    }
    $checks['status_ok'] = !is_null($dummy);
    if (!$checks['status_ok']) {
        $checks['msg'][] = sprintf($l10n['tproject_id_not_found'], $context->tprojectID);
    }
    if (!$checks['status_ok']) {
        foreach ($checks['msg'] as $warning) {
            $resultMap[] = array($warning);
        }
    }
    if ($doIt = $checks['status_ok']) {
        $context->tprojectID = $dummy[0]['id'];
    }
    // --------------------------------------------------------------------
    $dummy = null;
    if (!is_null($context->tplanID) && intval($context->tplanID) > 0) {
        $dummy = $tplan_mgr->get_by_id($context->tplanID, array('output' => 'minimun'));
        if (!is_null($dummy)) {
            $dummy['id'] = $context->tplanID;
        }
    } else {
        if (!is_null($context->tplanName)) {
            $dummy = $tplan_mgr->get_by_name($context->tplanName, $context->tprojectID, array('output' => 'minimun'));
            if (!is_null($dummy)) {
                $dummy = $dummy[0];
            }
        }
    }
    if (!is_null($dummy)) {
        $context->tplanID = $dummy['id'];
    }
    if (intval($context->tprojectID) <= 0 && intval($context->tplanID) > 0) {
        $dummy = $tplan_mgr->tree_manager->get_node_hierarchy_info($context->tplanID);
        $context->tprojectID = $dummy['parent_id'];
    }
    // --------------------------------------------------------------------
    // --------------------------------------------------------------------
    $dummy = null;
    $tplan_mgr->platform_mgr->setTestProjectID($context->tprojectID);
    if (!is_null($context->platformID) && intval($context->platformID) > 0) {
        $dummy = array($tplan_mgr->platform_mgr->getByID($context->platformID));
    } else {
        if (property_exists($context, 'platformName') && !is_null($context->platformName)) {
            if (!is_null($xx = $tplan_mgr->platform_mgr->getID($context->platformName))) {
                $dummy = array(0 => array('id' => $xx));
            }
        }
    }
    if (!is_null($dummy)) {
        $context->platformID = $dummy[0]['id'];
    }
    // --------------------------------------------------------------------
    // --------------------------------------------------------------------
    $optGB = array('tplan_id' => $context->tplanID, 'output' => 'minimun');
    $dummy = null;
    if (!is_null($context->buildID) && intval($context->buildID) > 0) {
        $dummy = array($build_mgr->get_by_id($context->buildID, $optGB));
    } else {
        if (!is_null($context->buildName)) {
            $dummy = $build_mgr->get_by_name($context->buildName, $optGB);
        }
    }
    if (!is_null($dummy)) {
        $context->buildID = $dummy[0]['id'];
    }
    // --------------------------------------------------------------------
    // --------------------------------------------------------------------
    for ($idx = 0; $doIt && $idx < $tc_qty; $idx++) {
        $tester_id = 0;
        $tester_name = '';
        $using_external_id = false;
        $message = null;
        $status_ok = true;
        $tcase_exec = $resultData[$idx];
        // New attribute "execution type" makes old XML import files incompatible
        // Important NOTICE:
        // tcase_exec is passed BY REFERENCE to allow check_exec_values()change execution type if needed
        //
        $checks = check_exec_values($db, $tcase_mgr, $user_mgr, $tcaseCfg, $tcase_exec, $columnDef['execution_bugs']);
        $status_ok = $checks['status_ok'];
        if ($status_ok) {
            $tcase_id = $checks['tcase_id'];
            $tcase_external_id = trim($tcase_exec['tcase_external_id']);
            $tester_id = $checks['tester_id'];
            // external_id has precedence over internal id
            $using_external_id = $tcase_external_id != "";
        } else {
            foreach ($checks['msg'] as $warning) {
                $resultMap[] = array($warning);
            }
        }
        if ($status_ok) {
            $tcase_identity = $using_external_id ? $tcase_external_id : $tcase_id;
            $result_code = strtolower($tcase_exec['result']);
            $result_is_acceptable = isset($resultsCfg['code_status'][$result_code]) ? true : false;
            $notes = $tcase_exec['notes'];
            $message = null;
            $info_on_case = $tplan_mgr->getLinkInfo($context->tplanID, $tcase_id, $context->platformID);
            if (is_null($info_on_case)) {
                $message = sprintf($l10n['import_results_tc_not_found'], $tcase_identity);
            } else {
                if (!$result_is_acceptable) {
                    $message = sprintf($l10n['import_results_invalid_result'], $tcase_identity, $tcase_exec['result']);
                } else {
                    $info_on_case = current($info_on_case);
                    $tcversion_id = $info_on_case['tcversion_id'];
                    $version = $info_on_case['version'];
                    $notes = $db->prepare_string(trim($notes));
                    // N.B.: db_now() returns an string ready to be used in an SQL insert
                    //       example '2008-09-04', while $tcase_exec["timestamp"] => 2008-09-04
                    //
                    $execution_ts = $tcase_exec['timestamp'] != '' ? "'" . $tcase_exec["timestamp"] . "'" : $db->db_now();
                    if ($tester_id != 0) {
                        $tester_name = $tcase_exec['tester'];
                    } else {
                        $tester_name = $user->login;
                        $tester_id = $context->userID;
                    }
                    $addExecDuration = strlen($tcase_exec['execution_duration']) > 0 && is_numeric($tcase_exec['execution_duration']);
                    $lexid = 0;
                    if ($options->copyIssues) {
                        $lexid = $tcase_mgr->getSystemWideLastestExecutionID($tcversion_id);
                    }
                    $idCard = array('id' => $tcase_id, 'version_id' => $tcversion_id);
                    $exco = array('tplan_id' => $context->tplanID, 'platform_id' => $context->platformID, 'build_id' => $context->buildID);
                    $lexInfo = $tcase_mgr->getLatestExecSingleContext($idCard, $exco, array('output' => 'timestamp'));
                    $doInsert = true;
                    if (!is_null($lexInfo)) {
                        $tts = $lexInfo[$tcase_id][0]['execution_ts'];
                        $doInsert = $lexInfo[$tcase_id][0]['execution_ts'] != trim($execution_ts, "'");
                        $msgTxt = $l10n['import_results_skipped'];
                    }
                    if ($doInsert) {
                        $sql = " /* {$debugMsg} */ " . " INSERT INTO {$tables['executions']} (build_id,tester_id,status,testplan_id," . " tcversion_id,execution_ts,notes,tcversion_number,platform_id,execution_type" . ($addExecDuration ? ',execution_duration' : '') . ")" . " VALUES ({$context->buildID}, {$tester_id},'{$result_code}',{$context->tplanID}, " . " {$tcversion_id},{$execution_ts},'{$notes}', {$version}, " . " {$context->platformID}, {$tcase_exec['execution_type']}" . ($addExecDuration ? ",{$tcase_exec['execution_duration']}" : '') . ")";
                        $db->exec_query($sql);
                        $execution_id = $db->insert_id($tables['executions']);
                        // 20150127
                        /*
                        if(isset($tcase_exec['steps']) && !is_null($tcase_exec['steps']))
                        {
                          $stepSet = $tcase_mgr->getStepsSimple($tcversion_id,0,
                                                                array('fields2get' => 'TCSTEPS.step_number,TCSTEPS.id',
                                                                      'accessKey' => 'step_number'));
                          $sc = count($tcase_exec['steps']);
                          for($sx=0; $sx < $sc; $sx++)
                          {
                            $snum = $$tcase_exec['steps'][$sx];
                            // assumption: all data is valid
                            if(isset($stepSet[$snum]))
                            {
                              
                            }  
                          }  
                        }  
                        new dBug($tcase_exec);
                        die();
                        */
                        if ($lexid > 0 && $options->copyIssues) {
                            copyIssues($db, $lexid, $execution_id);
                        }
                        if (isset($tcase_exec['bug_id']) && !is_null($tcase_exec['bug_id']) && is_array($tcase_exec['bug_id'])) {
                            foreach ($tcase_exec['bug_id'] as $bug_id) {
                                $bug_id = trim($bug_id);
                                $sql = " /* {$debugMsg} */ " . " SELECT execution_id AS check_qty FROM  {$tables['execution_bugs']} " . " WHERE bug_id = '{$bug_id}' AND execution_id={$execution_id} ";
                                $rs = $db->get_recordset($sql);
                                if (is_null($rs)) {
                                    $sql = " /* {$debugMsg} */ " . " INSERT INTO {$tables['execution_bugs']} (bug_id,execution_id)" . " VALUES ('" . $db->prepare_string($bug_id) . "', {$execution_id} )";
                                    $db->exec_query($sql);
                                }
                            }
                        }
                        if (isset($tcase_exec['custom_fields']) && !is_null($tcase_exec['custom_fields']) && is_array($tcase_exec['custom_fields'])) {
                            // Get linked custom fields to this test project, for test case on execution
                            // $context->tprojectID
                            $cfieldMgr = new cfield_mgr($db);
                            $cfSetByName = $cfieldMgr->get_linked_cfields_at_execution($context->tprojectID, 1, 'testcase', null, null, null, 'name');
                            foreach ($tcase_exec['custom_fields'] as $cf) {
                                $ak = null;
                                if (isset($cfSetByName[$cf['name']])) {
                                    // write to db blind
                                    $ak[$cfSetByName[$cf['name']]['id']]['cf_value'] = $cf['value'];
                                } else {
                                    $message = sprintf($l10n['invalid_cf'], $tcase_identity, $cf['name']);
                                }
                                if (!is_null($ak)) {
                                    $cfieldMgr->execution_values_to_db($ak, $tcversion_id, $execution_id, $context->tplanID, null, 'plain');
                                }
                            }
                        }
                        if (!is_null($message)) {
                            $resultMap[] = array($message);
                        }
                        $msgTxt = $l10n['import_results_ok'];
                    }
                    $message = sprintf($msgTxt, $tcase_identity, $version, $tester_name, $l10n[$result_code], $execution_ts);
                }
            }
        }
        if (!is_null($message)) {
            $resultMap[] = array($message);
        }
    }
    return $resultMap;
}