示例#1
0
function importResults(&$db, &$xml, $context)
{
    $resultMap = null;
    if ($xml->getName() == 'results') {
        // check if additional data (context execution) has been provided,
        // if yes overwrite GUI selection with value get from file
        //
        $executionContext = $context;
        $contextKeys = array('testproject' => array('id' => 'tprojectID', 'name' => 'tprojectName'), 'testplan' => array('id' => 'tplanID', 'name' => 'tplanName'), 'build' => array('id' => 'buildID', 'name' => 'buildName'), 'platform' => array('id' => 'platformID', 'name' => 'platformName'));
        foreach ($contextKeys as $xmlkey => $execElem) {
            if ($joker = $xml->{$xmlkey}) {
                // IMPORTANT NOTICE: name has precedence over id
                if (isset($joker['name'])) {
                    $executionContext->{$execElem}['name'] = (string) $joker['name'];
                    $executionContext->{$execElem}['id'] = null;
                    // get rid of id passed from GUI
                    continue;
                }
                if (isset($joker['id'])) {
                    $executionContext->{$execElem}['id'] = (int) $joker['id'];
                    $executionContext->{$execElem}['name'] = null;
                }
            }
        }
        $xmlTCExec = $xml->xpath("//testcase");
        $resultData = importExecutionsFromXML($xmlTCExec);
        if ($resultData) {
            $resultMap = saveImportedResultData($db, $resultData, $executionContext);
        }
    }
    return $resultMap;
}
示例#2
0
function importResults(&$db, &$xml, $context)
{
    $resultMap = null;
    if ($xml->getName() == 'results') {
        // check if additional data (context execution) has been provided,
        // if yes overwrite GUI selection with value get from file
        //
        $executionContext = $context;
        $contextKeys = array('testproject' => 'tprojectID', 'testplan' => 'tplanID', 'build' => 'buildID', 'platform' => 'platformID');
        foreach ($contextKeys as $xmlkey => $execkey) {
            if ($joker = $xml->{$xmlkey}) {
                $executionContext->{$execkey} = (int) $joker['id'];
            }
        }
        $xmlTCExec = $xml->xpath("//testcase");
        $resultData = importExecutionsFromXML($xmlTCExec);
        if ($resultData) {
            $resultMap = saveImportedResultData($db, $resultData, $executionContext);
        }
    }
    return $resultMap;
}