Merge branch 'sprint/autoTest_liumengyi_bug' into 'master'

* Add auto test of bug.

See merge request easycorp/zentaopms!2361
This commit is contained in:
孙广明
2022-03-18 02:53:05 +00:00
4 changed files with 170 additions and 3 deletions
+103
View File
@@ -785,4 +785,107 @@ class bugTest
return $owner;
}
}
/**
* Test update a bug.
*
* @param mixed $bugID
* @param array $param
* @access public
* @return void
*/
public function updateObject($bugID, $param = array())
{
global $tester;
$object = $tester->dbh->query("SELECT * FROM " . TABLE_BUG ." WHERE id = $bugID")->fetch();
foreach($object as $field => $value)
{
if(in_array($field, array_keys($param)))
{
$_POST[$field] = $param[$field];
}
else
{
$_POST[$field] = $value;
}
}
$_POST['closedDate'] = '';
$change = $this->objectModel->update($bugID);
if($change == array()) $change = '没有数据更新';
unset($_POST);
if(dao::isError())
{
return dao::getError();
}
else
{
return $change;
}
}
/**
* Test batch update tasks.
*
* @param array $param
* @param int $taskID
* @access public
* @return array
*/
public function batchUpdateObject($bugIDList, $title, $type, $bugID)
{
$titles = array('1' => 'BUG1', '2' => 'BUG2', '3' => 'BUG3');
$types = array('1' => 'codeerror', '2' => 'config', '3' => 'install');
$severities = array('1' => '1', '2' => '2', '3' => '3');
$pris = array('1' => '1', '2' => '2', '3' => '3');
$colors = array('1' => '#3da7f5', '2' => '#75c941', '3' => '#2dbdb2');
$module = array('1' => '1821', '2' => '1822', '3' => '1823');
$plan = array('1' => '1', '2' => '1', '3' => '1');
$assignedTo = array('1' => 'admin', '2' => 'admin', '3' => 'admin');
$deadline = array('1' => date('Y-m-d',strtotime('-1 month')), '2' => date('Y-m-d',strtotime('-1 month +1 day')), '3' => date('Y-m-d',strtotime('-1 month +2 day')));
$os = array('1' => '', '2' => '', '3' => 'all');
$browser = array('1' => '', '2' => '', '3' => '');
$keyword = array('1' => '', '2' => '', '3' => '');
$resolvedBy = array('1' => '', '2' => '', '3' => '');
$resolution = array('1' => '', '2' => '', '3' => '');
$duplicateBug = array('1' => '', '2' => '', '3' => '');
$titles[$bugID] = $title;
$types[$bugID] = $type;
$batchUpdateFields['bugIDList'] = $bugIDList;
$batchUpdateFields['types'] = $types;
$batchUpdateFields['severities'] = $severities;
$batchUpdateFields['pris'] = $pris;
$batchUpdateFields['titles'] = $titles;
$batchUpdateFields['colors'] = $colors;
$batchUpdateFields['modules'] = $module;
$batchUpdateFields['plans'] = $plan;
$batchUpdateFields['assignedTos'] = $assignedTo;
$batchUpdateFields['deadlines'] = $deadline;
$batchUpdateFields['os'] = $os;
$batchUpdateFields['browsers'] = $browser;
$batchUpdateFields['keywords'] = $keyword;
$batchUpdateFields['resolvedBys'] = $resolvedBy;
$batchUpdateFields['resolutions'] = $resolution;
$batchUpdateFields['duplicateBugs'] = $duplicateBug;
foreach($batchUpdateFields as $field => $value) $_POST[$field] = $value;
$object = $this->objectModel->batchUpdate();
unset($_POST);
if(dao::isError())
{
return dao::getError();
}
else
{
return $object[$bugID];
}
}
}
+3 -3
View File
@@ -35,9 +35,9 @@ fields:
- field: keywords
range: []
- field: severity
range: 1-4:R
range: 1-4
- field: pri
range: 1-4:R
range: 1-4
- field: type
range: [codeerror,config,install,security,performance,standard,automation,designdefect,others]
- field: os
@@ -97,7 +97,7 @@ fields:
loop: 0
format: "YYYY-MM-DD"
- field: closedBy
range: []{80},admin{20}
range: []{50},admin{30}
- field: closedDate
range:
- field: duplicateBug
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/bug.class.php';
su('admin');
/**
title=测试bugModel->batchUpdate();
cid=1
pid=1
测试批量修改bug1 >> type,codeerror,config;title,BUG1,批量修改bug一
测试批量修改bug2 >> type,config,install;title,BUG2,批量修改bug二
测试批量修改bug3 >> type,install,security;title,BUG3,批量修改bug三
*/
$bugIDList = array('1', '2', '3');
$title = array('1' => '批量修改bug一', '2' => '批量修改bug二', '3' => '批量修改bug三');
$type = array('1' => 'config', '2' => 'install', '3' => 'security');
$bug = new bugTest();
r($bug->batchUpdateObject($bugIDList, $title[$bugIDList[0]], $type[$bugIDList[0]], $bugIDList[0])) && p('0:field,old,new;1:field,old,new') && e('type,codeerror,config;title,BUG1,批量修改bug一'); // 测试批量修改bug1
r($bug->batchUpdateObject($bugIDList, $title[$bugIDList[1]], $type[$bugIDList[1]], $bugIDList[1])) && p('0:field,old,new;1:field,old,new') && e('type,config,install;title,BUG2,批量修改bug二'); // 测试批量修改bug2
r($bug->batchUpdateObject($bugIDList, $title[$bugIDList[2]], $type[$bugIDList[2]], $bugIDList[2])) && p('0:field,old,new;1:field,old,new') && e('type,install,security;title,BUG3,批量修改bug三'); // 测试批量修改bug3
system("./ztest init");
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php'; su('admin');
include dirname(dirname(dirname(__FILE__))) . '/class/bug.class.php';
/**
title=bugModel->update();
cid=1
pid=1
测试更新bug名称 >> title,BUG1,john
测试更新bug类型 >> type,codeerror,config
测试更新bug名称和类型 >> title,john,jack;type,config,install
测试不更改bug名称 >> 没有数据更新
测试不更改bug类型 >> 没有数据更新
*/
$projectIdList = array('1', '2');
$t_uptitle = array('title' => 'john');
$t_uptype = array('type' => 'config');
$t_typetitle = array('title' => 'jack', 'type' => 'install');
$t_untitle = array('title' => 'jack');
$t_untype = array('type' => 'install');
$bug=new bugTest();
r($bug->updateObject($projectIdList[0], $t_uptitle)) && p('0:field,old,new') && e('title,正常bug2,john'); // 测试更新bug名称
r($bug->updateObject($projectIdList[0], $t_uptype)) && p('0:field,old,new') && e('type,codeerror,config'); // 测试更新bug类型
r($bug->updateObject($projectIdList[0], $t_typetitle)) && p('0:field,old,new;1:field,old,new') && e('title,john,jack;type,config,install'); // 测试更新bug名称和类型
r($bug->updateObject($projectIdList[0], $t_untitle)) && p() && e('没有数据更新'); // 测试不更改bug名称
r($bug->updateObject($projectIdList[0], $t_untype)) && p() && e('没有数据更新'); // 测试不更改bug类型
system("./ztest init");