Example #1
0
 function exportTestSuiteDataToXML($container_id, $tproject_id, $optExport = array())
 {
     static $keywordMgr;
     if (is_null($keywordMgr)) {
         $keywordMgr = new tlKeyword();
     }
     // echo __FUNCTION__ . '<br>';
     $xmlTC = null;
     $doRecursion = isset($optExport['RECURSIVE']) ? $optExport['RECURSIVE'] : 0;
     if ($doRecursion) {
         $cfXML = null;
         $kwXML = null;
         $tsuiteData = $this->get_by_id($container_id);
         if (@$optExport['KEYWORDS']) {
             $kwMap = $this->getKeywords($container_id);
             if ($kwMap) {
                 $kwXML = "<keywords>" . $keywordMgr->toXMLString($kwMap, true) . "</keywords>";
             }
         }
         if ($optExport['CFIELDS']) {
             // 20090106 - franciscom - custom fields
             $cfMap = $this->get_linked_cfields_at_design($container_id, null, null, $tproject_id);
             if (!is_null($cfMap) && count($cfMap) > 0) {
                 $cfRootElem = "<custom_fields>{{XMLCODE}}</custom_fields>";
                 $cfElemTemplate = "\t" . '<custom_field><name><![CDATA[' . "\n||NAME||\n]]>" . "</name>" . '<value><![CDATA[' . "\n||VALUE||\n]]>" . '</value></custom_field>' . "\n";
                 $cfDecode = array("||NAME||" => "name", "||VALUE||" => "value");
                 $cfXML = exportDataToXML($cfMap, $cfRootElem, $cfElemTemplate, $cfDecode, true);
             }
         }
         $xmlTC = "<testsuite name=\"" . htmlspecialchars($tsuiteData['name']) . '" >' . "\n<node_order><![CDATA[{$tsuiteData['node_order']}]]></node_order>\n" . "<details><![CDATA[{$tsuiteData['details']}]]> \n{$kwXML}{$cfXML}</details>";
     } else {
         $xmlTC = "<testcases>";
     }
     $test_spec = $this->get_subtree($container_id, self::USE_RECURSIVE_MODE);
     $childNodes = isset($test_spec['childNodes']) ? $test_spec['childNodes'] : null;
     $tcase_mgr = null;
     if (!is_null($childNodes)) {
         $loop_qty = sizeof($childNodes);
         for ($idx = 0; $idx < $loop_qty; $idx++) {
             $cNode = $childNodes[$idx];
             $nTable = $cNode['node_table'];
             if ($doRecursion && $nTable == 'testsuites') {
                 $xmlTC .= $this->exportTestSuiteDataToXML($cNode['id'], $tproject_id, $optExport);
             } else {
                 if ($nTable == 'testcases') {
                     if (is_null($tcase_mgr)) {
                         $tcase_mgr = new testcase($this->db);
                     }
                     $xmlTC .= $tcase_mgr->exportTestCaseDataToXML($cNode['id'], testcase::LATEST_VERSION, $tproject_id, true, $optExport);
                 }
             }
         }
     }
     $xmlTC .= $doRecursion ? "</testsuite>" : "</testcases>";
     return $xmlTC;
 }
 /**
  * 
  *
  */
 private function exportTestSuiteDataToXML($container, $tproject_id, $tplan_id, $platform_id)
 {
     static $keywordMgr;
     static $getLastVersionOpt = array('output' => 'minimun');
     static $tcaseMgr;
     static $tsuiteMgr;
     static $tcaseExportOptions;
     static $linkedItems;
     if (is_null($keywordMgr)) {
         $tcaseExportOptions = array('CFIELDS' => true, 'KEYWORDS' => true, 'EXEC_ORDER' => 0);
         $keywordMgr = new tlKeyword();
         $tsuiteMgr = new testsuite($this->db);
         $linkedItems = $this->getLinkedItems($tplan_id);
     }
     $xmlTC = null;
     $cfXML = null;
     $kwXML = null;
     if (isset($container['id'])) {
         $kwMap = $tsuiteMgr->getKeywords($container['id']);
         if ($kwMap) {
             $kwXML = "<keywords>" . $keywordMgr->toXMLString($kwMap, true) . "</keywords>";
         }
         $cfMap = (array) $tsuiteMgr->get_linked_cfields_at_design($container['id'], null, null, $tproject_id);
         if (count($cfMap) > 0) {
             $cfXML = $this->cfield_mgr->exportValueAsXML($cfMap);
         }
         $tsuiteData = $tsuiteMgr->get_by_id($container['id']);
         $xmlTC = "\n\t<testsuite name=\"" . htmlspecialchars($tsuiteData['name']) . '" >' . "\n\t\t<node_order><![CDATA[{$tsuiteData['node_order']}]]></node_order>" . "\n\t\t<details><![CDATA[{$tsuiteData['details']}]]>" . "\n\t\t{$kwXML}{$cfXML}</details>";
     }
     $childNodes = isset($container['childNodes']) ? $container['childNodes'] : null;
     if (!is_null($childNodes)) {
         $loop_qty = sizeof($childNodes);
         for ($idx = 0; $idx < $loop_qty; $idx++) {
             $cNode = $childNodes[$idx];
             switch ($cNode['node_table']) {
                 case 'testsuites':
                     $xmlTC .= $this->exportTestSuiteDataToXML($cNode, $tproject_id, $tplan_id, $platform_id);
                     break;
                 case 'testcases':
                     if (is_null($tcaseMgr)) {
                         $tcaseMgr = new testcase($this->db);
                     }
                     // testcase::LATEST_VERSION,
                     $tcaseExportOptions['EXEC_ORDER'] = $linkedItems[$cNode['id']][$platform_id]['node_order'];
                     $xmlTC .= $tcaseMgr->exportTestCaseDataToXML($cNode['id'], $cNode['tcversion_id'], $tproject_id, testcase::NOXMLHEADER, $tcaseExportOptions);
                     break;
             }
         }
     }
     if (isset($container['id'])) {
         $xmlTC .= "</testsuite>";
     }
     return $xmlTC;
 }
Example #3
0
/**
 * 
 *
 */
function tcaseSetAsXML(&$dbHandler, $contextSet)
{
    $tcaseMgr = new testcase($dbHandler);
    $tcversionSet = explode(',', $contextSet->tcversionSet);
    $xmlTC = "<testcases>\n\t";
    foreach ($tcversionSet as $tcversion_id) {
        $xmlTC .= $tcaseMgr->exportTestCaseDataToXML(0, $tcversion_id, $contextSet->tproject_id, true);
    }
    $xmlTC .= "</testcases>\n\t";
    return $xmlTC;
}
 function exportTestSuiteDataToXML($container_id, $tproject_id, $optExport = array())
 {
     static $keywordMgr;
     static $getLastVersionOpt = array('output' => 'minimun');
     static $tcase_mgr;
     if (is_null($keywordMgr)) {
         $keywordMgr = new tlKeyword();
     }
     $xmlTC = null;
     $doRecursion = isset($optExport['RECURSIVE']) ? $optExport['RECURSIVE'] : 0;
     if ($doRecursion) {
         $cfXML = null;
         $kwXML = null;
         $tsuiteData = $this->get_by_id($container_id);
         if (isset($optExport['KEYWORDS']) && $optExport['KEYWORDS']) {
             $kwMap = $this->getKeywords($container_id);
             if ($kwMap) {
                 $kwXML = "<keywords>" . $keywordMgr->toXMLString($kwMap, true) . "</keywords>";
             }
         }
         if (isset($optExport['CFIELDS']) && $optExport['CFIELDS']) {
             $cfMap = (array) $this->get_linked_cfields_at_design($container_id, null, null, $tproject_id);
             if (count($cfMap) > 0) {
                 $cfXML = $this->cfield_mgr->exportValueAsXML($cfMap);
             }
         }
         $xmlTC = "<testsuite name=\"" . htmlspecialchars($tsuiteData['name']) . '" >' . "\n<node_order><![CDATA[{$tsuiteData['node_order']}]]></node_order>\n" . "<details><![CDATA[{$tsuiteData['details']}]]> \n{$kwXML}{$cfXML}</details>";
     } else {
         $xmlTC = "<testcases>";
     }
     $test_spec = $this->get_subtree($container_id, self::USE_RECURSIVE_MODE);
     $childNodes = isset($test_spec['childNodes']) ? $test_spec['childNodes'] : null;
     $tcase_mgr = null;
     if (!is_null($childNodes)) {
         $loop_qty = sizeof($childNodes);
         for ($idx = 0; $idx < $loop_qty; $idx++) {
             $cNode = $childNodes[$idx];
             $nTable = $cNode['node_table'];
             if ($doRecursion && $nTable == 'testsuites') {
                 $xmlTC .= $this->exportTestSuiteDataToXML($cNode['id'], $tproject_id, $optExport);
             } else {
                 if ($nTable == 'testcases') {
                     if (is_null($tcase_mgr)) {
                         $tcase_mgr = new testcase($this->db);
                     }
                     $xmlTC .= $tcase_mgr->exportTestCaseDataToXML($cNode['id'], testcase::LATEST_VERSION, $tproject_id, true, $optExport);
                 }
             }
         }
     }
     $xmlTC .= $doRecursion ? "</testsuite>" : "</testcases>";
     return $xmlTC;
 }
Example #5
0
 function exportTestSuiteDataToXML($container_id, $tproject_id, $optExport = array())
 {
     static $keywordMgr;
     static $getLastVersionOpt = array('output' => 'minimun');
     static $tcase_mgr;
     if (is_null($keywordMgr)) {
         $keywordMgr = new tlKeyword();
     }
     $xmlTC = null;
     $relCache = array();
     $doRecursion = isset($optExport['RECURSIVE']) ? $optExport['RECURSIVE'] : 0;
     if ($doRecursion) {
         $cfXML = null;
         $kwXML = null;
         $tsuiteData = $this->get_by_id($container_id);
         if (isset($optExport['KEYWORDS']) && $optExport['KEYWORDS']) {
             $kwMap = $this->getKeywords($container_id);
             if ($kwMap) {
                 $kwXML = "<keywords>" . $keywordMgr->toXMLString($kwMap, true) . "</keywords>";
             }
         }
         if (isset($optExport['CFIELDS']) && $optExport['CFIELDS']) {
             $cfMap = (array) $this->get_linked_cfields_at_design($container_id, null, null, $tproject_id);
             if (count($cfMap) > 0) {
                 $cfXML = $this->cfield_mgr->exportValueAsXML($cfMap);
             }
         }
         $xmlTC = '<testsuite id="' . $tsuiteData['id'] . '" ' . 'name="' . htmlspecialchars($tsuiteData['name']) . '" >' . "\n<node_order><![CDATA[{$tsuiteData['node_order']}]]></node_order>\n" . "<details><![CDATA[{$tsuiteData['details']}]]></details> \n{$kwXML}{$cfXML}";
     } else {
         $xmlTC = "<testcases>";
     }
     $test_spec = $this->get_subtree($container_id, self::USE_RECURSIVE_MODE);
     $childNodes = isset($test_spec['childNodes']) ? $test_spec['childNodes'] : null;
     $tcase_mgr = null;
     $relXmlData = '';
     if (!is_null($childNodes)) {
         $loop_qty = sizeof($childNodes);
         for ($idx = 0; $idx < $loop_qty; $idx++) {
             $cNode = $childNodes[$idx];
             $nTable = $cNode['node_table'];
             if ($doRecursion && $nTable == 'testsuites') {
                 $xmlTC .= $this->exportTestSuiteDataToXML($cNode['id'], $tproject_id, $optExport);
             } else {
                 if ($nTable == 'testcases') {
                     if (is_null($tcase_mgr)) {
                         $tcase_mgr = new testcase($this->db);
                     }
                     $xmlTC .= $tcase_mgr->exportTestCaseDataToXML($cNode['id'], testcase::LATEST_VERSION, $tproject_id, true, $optExport);
                     // 20140816
                     // Collect and do cache of all test case relations that exists inside this test suite.
                     $relSet = $tcase_mgr->getRelations($cNode['id']);
                     if ($relSet['num_relations'] > 0) {
                         foreach ($relSet['relations'] as $key => $rel) {
                             // If we have already found this relation, skip it.
                             if (!in_array($rel['id'], $relCache)) {
                                 $relXmlData .= $tcase_mgr->exportRelationToXML($rel, $relSet['item']);
                                 $relCache[] = $rel['id'];
                             }
                         }
                     }
                 }
             }
         }
     }
     // after we scanned all relations and exported all relations to xml, let's output it to the XML buffer
     $xmlTC .= $relXmlData;
     $xmlTC .= $doRecursion ? "</testsuite>" : "</testcases>";
     return $xmlTC;
 }