Skip to content
Permalink
Browse files

fix: #0008675: Testsuite Operations Export does not export Requirements

  • Loading branch information...
fmancardi committed May 30, 2019
1 parent ebf5bf4 commit 69a7db14fafbf79ba01ed4db983fa1c2a9e9df5c
Showing with 31 additions and 47 deletions.
  1. +6 −4 lib/functions/testcase.class.php
  2. +21 −40 lib/functions/testsuite.class.php
  3. +4 −3 lib/testcases/tcExport.php
@@ -3955,8 +3955,9 @@ function: exportTestCaseDataToXML
*/
function exportTestCaseDataToXML($tcase_id,$tcversion_id,$tproject_id=null,
$bNoXMLHeader = false,$optExport = array()) {
function exportTestCaseDataToXML($tcase_id,$tcversion_id,
$tproject_id=null,$bNoXMLHeader = false,$optExport = array()) {
static $reqMgr;
static $keywordMgr;
static $cfieldMgr;
@@ -3974,13 +3975,14 @@ function exportTestCaseDataToXML($tcase_id,$tcversion_id,$tproject_id=null,
$tcase_id = $info['parent_id'];
}
$opt = array('getPrefix' => false);
if(!isset($optExport['EXTERNALID']) || $optExport['EXTERNALID']) {
$opt = array('getPrefix' => (isset($optExport['ADDPREFIX']) && $optExport['ADDPREFIX']));
}
$tc_data = $this->get_by_id($tcase_id,$tcversion_id,null,$opt);
$testCaseVersionID = $tc_data[0]['id'];
if (!$tproject_id) {
$tproject_id = $this->getTestProjectFromTestCase($tcase_id);
}
@@ -4014,7 +4016,7 @@ function exportTestCaseDataToXML($tcase_id,$tcversion_id,$tproject_id=null,
// $requirements = $reqMgr->get_all_for_tcase($tcase_id);
// Need to get only for test case version
$req4version = $reqMgr->getGoodForTCVersion($tcversion_id);
$req4version = $reqMgr->getGoodForTCVersion($testCaseVersionID);
if( !is_null($req4version) && count($req4version) > 0 ) {
$tc_data[0]['xmlrequirements'] =
@@ -1140,43 +1140,35 @@ function: exportTestSuiteDataToXML
args :
returns:
@internal revisions
*/
function exportTestSuiteDataToXML($container_id,$tproject_id,$optExport = array())
{
function exportTestSuiteDataToXML($container_id,$tproject_id,$optExport = array()) {
static $keywordMgr;
static $getLastVersionOpt = array('output' => 'minimun');
static $tcase_mgr;
if(is_null($keywordMgr))
{
if(is_null($keywordMgr)) {
$keywordMgr = new tlKeyword();
}
$xmlTC = null;
$relCache = array();
$doRecursion = isset($optExport['RECURSIVE']) ? $optExport['RECURSIVE'] : 0;
if($doRecursion)
{
if($doRecursion) {
$cfXML = null;
$attachmentsXML = null;
$kwXML = null;
$tsuiteData = $this->get_by_id($container_id);
if( isset($optExport['KEYWORDS']) && $optExport['KEYWORDS'])
{
if( isset($optExport['KEYWORDS']) && $optExport['KEYWORDS']) {
$kwMap = $this->getKeywords($container_id);
if ($kwMap)
{
if ($kwMap) {
$kwXML = "<keywords>" . $keywordMgr->toXMLString($kwMap,true) . "</keywords>";
}
}
if (isset($optExport['CFIELDS']) && $optExport['CFIELDS'])
{
if (isset($optExport['CFIELDS']) && $optExport['CFIELDS']) {
$cfMap = (array)$this->get_linked_cfields_at_design($container_id,null,null,$tproject_id);
if( count($cfMap) > 0 )
{
if( count($cfMap) > 0 ) {
$cfXML = $this->cfield_mgr->exportValueAsXML($cfMap);
}
}
@@ -1188,15 +1180,12 @@ function exportTestSuiteDataToXML($container_id,$tproject_id,$optExport = array(
$attachmentInfos = $this->attachmentRepository->getAttachmentInfosFor($container_id,$this->attachmentTableName,'id');
// get all attachments content and encode it in base64
if ($attachmentInfos)
{
foreach ($attachmentInfos as $attachmentInfo)
{
if ($attachmentInfos) {
foreach ($attachmentInfos as $attachmentInfo) {
$aID = $attachmentInfo["id"];
$content = $this->attachmentRepository->getAttachmentContent($aID, $attachmentInfo);
if ($content != null)
{
if ($content != null) {
$attachments[$aID]["id"] = $aID;
$attachments[$aID]["name"] = $attachmentInfo["file_name"];
$attachments[$aID]["file_type"] = $attachmentInfo["file_type"];
@@ -1207,8 +1196,7 @@ function exportTestSuiteDataToXML($container_id,$tproject_id,$optExport = array(
}
}
if( !is_null($attachments) && count($attachments) > 0 )
{
if( !is_null($attachments) && count($attachments) > 0 ) {
$attchRootElem = "<attachments>\n{{XMLCODE}}</attachments>\n";
$attchElemTemplate = "\t<attachment>\n" .
"\t\t<id><![CDATA[||ATTACHMENT_ID||]]></id>\n" .
@@ -1233,9 +1221,7 @@ function exportTestSuiteDataToXML($container_id,$tproject_id,$optExport = array(
'name="' . htmlspecialchars($tsuiteData['name']). '" >' .
"\n<node_order><![CDATA[{$tsuiteData['node_order']}]]></node_order>\n" .
"<details><![CDATA[{$tsuiteData['details']}]]></details> \n{$kwXML}{$cfXML}{$attachmentsXML}";
}
else
{
} else {
$xmlTC = "<testcases>";
}
@@ -1244,25 +1230,20 @@ function exportTestSuiteDataToXML($container_id,$tproject_id,$optExport = array(
$childNodes = isset($test_spec['childNodes']) ? $test_spec['childNodes'] : null ;
$tcase_mgr=null;
$relXmlData = '';
if( !is_null($childNodes) )
{
if( !is_null($childNodes) ) {
$loop_qty=sizeof($childNodes);
for($idx = 0;$idx < $loop_qty;$idx++)
{
for($idx = 0;$idx < $loop_qty;$idx++) {
$cNode = $childNodes[$idx];
$nTable = $cNode['node_table'];
if ($doRecursion && $nTable == 'testsuites')
{
if ($doRecursion && $nTable == 'testsuites') {
$xmlTC .= $this->exportTestSuiteDataToXML($cNode['id'],$tproject_id,$optExport);
}
else if ($nTable == 'testcases')
{
if( is_null($tcase_mgr) )
{
} 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 .= $tcase_mgr->exportTestCaseDataToXML($cNode['id'],
testcase::LATEST_VERSION,
$tproject_id,true,$optExport);
// 20140816
@@ -139,9 +139,10 @@ function init_args(&$dbHandler) {
$args = new stdClass();
$args->doExport = isset($_REQUEST['export']) ? $_REQUEST['export'] : null;
$k2l = array('useRecursion','exportReqs','exportCFields','exportKeywords',
'exportTestCaseExternalID','exportTCSummary','exportTCPreconditions',
'exportTCSteps', 'exportAttachments');
$k2l = array('useRecursion','exportReqs','exportCFields',
'exportKeywords','exportTestCaseExternalID','exportTCSummary',
'exportTCPreconditions','exportTCSteps', 'exportAttachments');
foreach ($k2l as $key) {
$args->$key = isset($_REQUEST[$key]) ? intval($_REQUEST[$key]) : 0;
}

0 comments on commit 69a7db1

Please sign in to comment.
You can’t perform that action at this time.