コード例 #1
0
function importTestCaseDataFromXML(&$db, $fileName, $parentID, $tproject_id, $userID, $options = null)
{
    tLog('importTestCaseDataFromXML called for file: ' . $fileName);
    $xmlTCs = null;
    $resultMap = null;
    $my = array();
    $my['options'] = array('useRecursion' => false, 'importIntoProject' => 0, 'duplicateLogic' => array('hitCriteria' => 'name', 'actionOnHit' => null));
    $my['options'] = array_merge($my['options'], (array) $options);
    foreach ($my['options'] as $varname => $value) {
        ${$varname} = $value;
    }
    if (file_exists($fileName)) {
        $xml = @simplexml_load_file_wrapper($fileName);
        if ($xml !== FALSE) {
            $xmlKeywords = $xml->xpath('//keywords');
            $kwMap = null;
            if ($xmlKeywords) {
                $tproject = new testproject($db);
                $loop2do = sizeof($xmlKeywords);
                for ($idx = 0; $idx < $loop2do; $idx++) {
                    $tproject->importKeywordsFromSimpleXML($tproject_id, $xmlKeywords[$idx]);
                }
                $kwMap = $tproject->get_keywords_map($tproject_id);
                $kwMap = is_null($kwMap) ? null : array_flip($kwMap);
            }
            if (!$useRecursion && $xml->getName() == 'testcases') {
                $resultMap = importTestCasesFromSimpleXML($db, $xml, $parentID, $tproject_id, $userID, $kwMap, $duplicateLogic);
            }
            if ($useRecursion && $xml->getName() == 'testsuite') {
                $resultMap = importTestSuitesFromSimpleXML($db, $xml, intval($parentID), intval($tproject_id), $userID, $kwMap, $importIntoProject, $duplicateLogic);
            }
        }
    }
    return $resultMap;
}