1. Testlink提交BUG到mantis方式简化
1.1. Testlink提交BUG链接修改
1.1.1. 执行用例时,提交BUG的窗口链接修改为链接到mantis提交问题的页面
修改testlink\gui\templates\execute\inc_exec_show_tc_exec.tpl
如下:
{if $tc_old_exec.build_is_open}
<a href="javascript.:open_bug_add_window({$gui->tproject_id},{$tc_old_exec.id},{$tc_old_exec.execution_id},'link')">
=》
{if $tc_old_exec.build_is_open}
{* 2013-01-06 luly 增加BUG时,进行testlink关联 *}
{* <a href="javascript.:open_bug_add_window({$gui->tproject_id},{$tc_old_exec.id},{$tc_old_exec.execution_id},'link')"> *}
<a href="http://192.168.134.120/mantis/bug_report_page.php?exec_id={$tc_old_exec.execution_id}" target='_blank'>
{* *********************************************************** *}
1.1.2. mantis 提交bug的时候判断是否有exec_id参数传入
修改mantis\bug_report_page.php
<input type="hidden" name="project_id" value="<?php echo $t_project_id ?>" />后增加一行:
<input type="hidden" name="exec_id" value="<?php echo $_GET["exec_id"]; ?>" />
如下:
<tr>
<td class="form-title" colspan="2">
<input type="hidden" name="m_id" value="<?php echo $f_master_bug_id ?>" />
<input type="hidden" name="project_id" value="<?php echo $t_project_id ?>" />
<?php echo lang_get( 'enter_report_details_title' ) ?>
</td>
</tr>
=》
<tr>
<td class="form-title" colspan="2">
<input type="hidden" name="m_id" value="<?php echo $f_master_bug_id ?>" />
<input type="hidden" name="project_id" value="<?php echo $t_project_id ?>" />
<!--2013-01-06 luly 增加BUG时,进行testlink关联-->
<input type="hidden" name="exec_id" value="<?php echo $_GET["exec_id"]; ?>" />
<!--***********************************************************--><?php echo lang_get( 'enter_report_details_title' ) ?>
</td>
</tr>
1.1.3. 在mantis目录下面新增bug_add_testlink.php页面,进行testlink和mantis的BUG关联的处理
新增:mantis\bug_add_testlink.php
<?php
//2013-01-06 luly 增加BUG时,进行testlink关联
function write_execution_bug($exec_id, $bug_id,$just_delete=false)
{
$conn = mysql_connect("localhost","root","");
$execution_bugs = 'testlink.ttexecution_bugs';
// Instead of Check if record exists before inserting, do delete + insert
$sql = "DELETE FROM {$execution_bugs} " .
"WHERE execution_id={$exec_id} " .
"AND bug_id='" . $bug_id ."'";
$result = mysql_query($sql,$conn);
if(!$just_delete)
{
$sql = "INSERT INTO {$execution_bugs} " .
"(execution_id,bug_id) " .
"VALUES({$exec_id},'" . $bug_id . "')";
$result = mysql_query($sql,$conn);
}
return $result ? 1 : 0;
}
?>
1.1.4. 修改bug_report.php,如果存在exec_id,则进行testlink和mantis的BUG关联
修改mantis\bug_report.php
(1)在一开始增加一句:
//2013-01-06 luly 增加BUG时,进行testlink关联
require_once( 'bug_add_testlink.php' );
//***********************************************************//
(2)修改如下内容:
$t_bug_id = $t_bug_data->create();
=》
//2013-01-06 luly 增加BUG时,进行testlink关联
//$t_bug_id = $t_bug_data->create();
$testlink_exec_id = $_POST["exec_id"];
if ($testlink_exec_id!= "")
{
$t_bug_id = $t_bug_data->create();
write_execution_bug($testlink_exec_id,$t_bug_id);
}
else
{
$t_bug_id = $t_bug_data->create();
}
//***********************************************************//
(3)修改如下内容:
<form method="post" action="<?php echo string_get_bug_report_url() ?>">
=》
<!--2013-01-06 luly 增加BUG时,进行testlink关联-->
<!--<form method="post" action="<?php echo string_get_bug_report_url() ?>">-->
<form method="post" action="<?php echo string_get_bug_report_url() ?>?exec_id=<?php echo $_POST['exec_id']; ?>">
<!--***********************************************************-->
1.2. Mantis删除BUG时,自动删除testlink关联
1.2.1. 修改bug_add_testlink.php 增加删除bug时,自动删除testlink关联的函数
修改mantis\bug_add_testlink.php
//2013-01-06 luly 删除BUG时,删除对应的testlink关联
function delete_testlink_bug($bug_id)
{
$conn = mysql_connect("localhost","root","");
$execution_bugs = 'testlink.ttexecution_bugs';
$sql = "DELETE FROM $execution_bugs WHERE bug_id = $bug_id ";
$result = mysql_query($sql,$conn);
return $result ? 1 : 0;
}
1.2.2. 修改bug_actiongroup.php,调用删除testlink关联的函数
修改mantis\bug_actiongroup.php
在开始增加:
//2013-01-06 luly 删除BUG时,删除对应的testlink关联
require_once( 'bug_add_testlink.php' );
//***********************************************************//
修改如下内容:
bug_delete( $t_bug_id );
=》
bug_delete( $t_bug_id );
//2013-01-06 luly 删除BUG时,删除对应的testlink关联
delete_testlink_bug($t_bug_id);