1. Testlink提交BUG到mantisbt****方式简化
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}
{\* 2016-09-12 xup 增加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://localhost:80/mantisbt/bug_report_page.php?exec_id={$tc_old_exec.execution_id}" target='_blank'>
{\* \*\*\*\*\*\*\*\*\*\*\*localhost需要换成公众都能访问的IP地址\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*}
1.1.2. mantis 提交bug的时候判断是否有exec_id参数传入
修改mantis**\**bug_report_page.php
后增加一行:
<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 ?>" />
<!--2016-09-12 xup 增加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
//2016-09-12 xup 增加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)在一开始增加一句:
//2016-09-12 xup 增加BUG时,进行testlink关联
require_once( 'bug_add_testlink.php' );
(2)修改如下内容:
$t_bug_id = $t_bug_data->create();
换成=》
//2016-09-12 xup 增加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() ?>">
换成=》
<!--2012-09-12 xup 增加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
//2016-09-12 xup 删除BUG时,删除对应的testlink关联 Mysql
function delete_testlink_bug($bug_id)
{
$conn = mysql_connect("localhost","root","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
在开始增加:
//2019-09-12 xup 删除BUG时,删除对应的testlink关联
require_once( 'bug_add_testlink.php' );
修改如下内容:
bug_delete( $t_bug_id );
换成=》
bug_delete( $t_bug_id );
//2016-09-12 xup 删除BUG时,删除对应的testlink关联
delete_testlink_bug($t_bug_id);