Merge branch 'sprint/autoTest_liumengyi_bug' into 'master'
* Add auto test of bug. See merge request easycorp/zentaopms!2381
This commit is contained in:
@@ -828,10 +828,12 @@ class bugTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Test batch update tasks.
|
||||
* Test batch update bugs.
|
||||
*
|
||||
* @param array $param
|
||||
* @param int $taskID
|
||||
* @param array $bugIDList
|
||||
* @param string $title
|
||||
* @param string $type
|
||||
* @param int $bugID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
@@ -888,4 +890,176 @@ class bugTest
|
||||
return $object[$bugID];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test batch activate bugs.
|
||||
*
|
||||
* @param array $bugIDList
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function batchActivateObject($bugIDList)
|
||||
{
|
||||
$statusList = array('1' => 'active', '53' => 'resolved', '82' => 'closed');
|
||||
$assignedToList = array('1' => 'admin', '53' => 'admin', '82' => 'admin');
|
||||
$openedBuildList = array('1' => 'trunk', '53' => 'trunk', '82' => 'trunk');
|
||||
$commentList = array('1' => '', '53' => '', '82' => '');
|
||||
|
||||
$batchActivateFields['bugIDList'] = $bugIDList;
|
||||
$batchActivateFields['statusList'] = $statusList;
|
||||
$batchActivateFields['assignedToList'] = $assignedToList;
|
||||
$batchActivateFields['openedBuildList'] = $openedBuildList;
|
||||
$batchActivateFields['commentList'] = $commentList;
|
||||
|
||||
foreach($batchActivateFields as $field => $value) $_POST[$field] = $value;
|
||||
|
||||
$object = $this->objectModel->batchActivate();
|
||||
unset($_POST);
|
||||
|
||||
if(dao::isError())
|
||||
{
|
||||
return dao::getError();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test assign a bug to a user again.
|
||||
*
|
||||
* @param int $bugID
|
||||
* @param array $param
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function assignTest($bugID, $param = array())
|
||||
{
|
||||
$createFields = array('assignedTo' => '', 'status' => '', 'comment' => '');
|
||||
foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue;
|
||||
foreach($param as $key => $value) $_POST[$key] = $value;
|
||||
$object = $this->objectModel->assign($bugID);
|
||||
unset($_POST);
|
||||
if(dao::isError())
|
||||
{
|
||||
return dao::getError();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test confirm a bug.
|
||||
*
|
||||
* @param int $bugID
|
||||
* @param array $param
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function confirmTest($bugID, $param = array())
|
||||
{
|
||||
$createFields = array('assignedTo' => '', 'status' => '', 'comment' => '', 'pri' => '1');
|
||||
foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue;
|
||||
foreach($param as $key => $value) $_POST[$key] = $value;
|
||||
$object = $this->objectModel->confirm($bugID);
|
||||
unset($_POST);
|
||||
if(dao::isError())
|
||||
{
|
||||
return dao::getError();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test batch confirm bugs.
|
||||
*
|
||||
* @param array $bugIDList
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function batchConfirmTest($bugIDList)
|
||||
{
|
||||
$this->objectModel->batchConfirm($bugIDList);
|
||||
|
||||
$bugs = $this->objectModel->getByList($bugIDList);
|
||||
|
||||
$confirm = '';
|
||||
foreach($bugs as $bug) $confirm .= ',' . $bug->confirmed;
|
||||
|
||||
if(dao::isError())
|
||||
{
|
||||
return dao::getError();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $confirm;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test confirm a bug.
|
||||
*
|
||||
* @param int $bugID
|
||||
* @param array $param
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function resolveTest($bugID, $param = array())
|
||||
{
|
||||
$createFields['duplicateBug'] = '';
|
||||
$createFields['buildExecution'] = '0';
|
||||
$createFields['resolvedBuild'] = 'trunk';
|
||||
$createFields['buildName'] = '';
|
||||
$createFields['resolvedDate'] = helper::now();
|
||||
$createFields['assignedTo'] = '';
|
||||
$createFields['status'] = 'resolved';
|
||||
$createFields['labels'] = array('');
|
||||
$createFields['comment'] = '';
|
||||
$createFields['resolution'] = '';
|
||||
|
||||
foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue;
|
||||
foreach($param as $key => $value) $_POST[$key] = $value;
|
||||
|
||||
$object = $this->objectModel->resolve($bugID);
|
||||
|
||||
unset($_POST);
|
||||
if(dao::isError())
|
||||
{
|
||||
return dao::getError();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test batch change branch.
|
||||
*
|
||||
* @param array $bugIDList
|
||||
* @param int $branchID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function batchChangeBranchTest($bugIDList, $branchID, $bugID)
|
||||
{
|
||||
$bugs = $this->objectModel->getByList($bugIDList);
|
||||
|
||||
$object = $this->objectModel->batchChangeBranch($bugIDList, $branchID, $bugs);
|
||||
|
||||
if(dao::isError())
|
||||
{
|
||||
return dao::getError();
|
||||
}
|
||||
else
|
||||
{
|
||||
return !empty($object[$bugID]) ? $object[$bugID] : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
40
test/model/bug/assign.php
Executable file
40
test/model/bug/assign.php
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/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->assign();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
指派bugID为1的bug >> assignedTo,admin,user92
|
||||
指派bugID为2的bug >> assignedTo,admin,user93
|
||||
指派bugID为3的bug >> assignedTo,admin,user94
|
||||
指派bugID为4的bug >> assignedTo,admin,user95
|
||||
指派bugID为51的bug >> assignedTo,dev1,user96
|
||||
指派bugid为81的bug >> assignedTo,test1,user97
|
||||
指派人不发生变化的bug >> 0
|
||||
|
||||
*/
|
||||
|
||||
$bugIDlist = array('1','2','3','4','51','81');
|
||||
|
||||
$bug1 = array('assignedTo' => 'user92', 'status' => 'active');
|
||||
$bug2 = array('assignedTo' => 'user93', 'status' => 'active');
|
||||
$bug3 = array('assignedTo' => 'user94', 'status' => 'active');
|
||||
$bug4 = array('assignedTo' => 'user95', 'status' => 'active');
|
||||
$bug51 = array('assignedTo' => 'user96', 'status' => 'active');
|
||||
$bug81 = array('assignedTo' => 'user97', 'status' => 'active');
|
||||
|
||||
$bug = new bugTest();
|
||||
r($bug->assignTest($bugIDlist[0],$bug1)) && p('0:field,old,new') && e('assignedTo,admin,user92'); // 指派bugID为1的bug
|
||||
r($bug->assignTest($bugIDlist[1],$bug2)) && p('0:field,old,new') && e('assignedTo,admin,user93'); // 指派bugID为2的bug
|
||||
r($bug->assignTest($bugIDlist[2],$bug3)) && p('0:field,old,new') && e('assignedTo,admin,user94'); // 指派bugID为3的bug
|
||||
r($bug->assignTest($bugIDlist[3],$bug4)) && p('0:field,old,new') && e('assignedTo,admin,user95'); // 指派bugID为4的bug
|
||||
r($bug->assignTest($bugIDlist[4],$bug51)) && p('0:field,old,new') && e('assignedTo,dev1,user96'); // 指派bugID为51的bug
|
||||
r($bug->assignTest($bugIDlist[5],$bug81)) && p('0:field,old,new') && e('assignedTo,test1,user97'); // 指派bugID为81的bug
|
||||
r($bug->assignTest($bugIDlist[5],$bug81)) && p() && e('0'); // 指派人不发生变化的bug
|
||||
system("./ztest init");
|
||||
21
test/model/bug/batchactivate.php
Executable file
21
test/model/bug/batchactivate.php
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/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->batchActivate();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
测试批量激活bug >> active;active
|
||||
|
||||
*/
|
||||
|
||||
$bugIDList = array('1' => '1', '52' => '53', '82' => '82');
|
||||
|
||||
$bug = new bugTest();
|
||||
r($bug->batchActivateObject($bugIDList)) && p('53:status;82:status') && e('active;active'); // 测试批量激活bug
|
||||
system("./ztest init");
|
||||
52
test/model/bug/batchchangebranch.php
Executable file
52
test/model/bug/batchchangebranch.php
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/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->batchChangeBranch();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
修改分支为主干 未发生变化 >> 0
|
||||
修改分支为分支11 >> branch,0,11
|
||||
修改分支为分支12 >> branch,11,12
|
||||
修改分支为主干 未发生变化 >> 0
|
||||
修改分支为分支9 >> branch,0,9
|
||||
修改分支为分支10 >> branch,9,10
|
||||
修改分支为主干 未发生变化 >> 0
|
||||
修改分支为分支7 >> branch,0,7
|
||||
修改分支为分支8 >> branch,7,8
|
||||
修改分支为主干 未发生变化 >> 0
|
||||
修改分支为分支37 >> branch,0,37
|
||||
修改分支为分支38 >> branch,37,38
|
||||
|
||||
*/
|
||||
|
||||
$bugIDList1 = array('136', '137', '138');
|
||||
$bugIDList2 = array('133', '134', '135');
|
||||
$bugIDList3 = array('130', '131', '132');
|
||||
$bugIDList4 = array('175', '176', '177');
|
||||
|
||||
$branchList1 = array('0', '11', '12');
|
||||
$branchList2 = array('0', '9', '10');
|
||||
$branchList3 = array('0', '7', '8');
|
||||
$branchList4 = array('0', '37', '38');
|
||||
|
||||
|
||||
$bug = new bugTest();
|
||||
r($bug->batchChangeBranchTest($bugIDList1, $branchList1[0], $bugIDList1[0])) && p() && e('0'); // 修改分支为主干 未发生变化
|
||||
r($bug->batchChangeBranchTest($bugIDList1, $branchList1[1], $bugIDList1[1])) && p('0:field,old,new') && e('branch,0,11'); // 修改分支为分支11
|
||||
r($bug->batchChangeBranchTest($bugIDList1, $branchList1[2], $bugIDList1[2])) && p('0:field,old,new') && e('branch,11,12'); // 修改分支为分支12
|
||||
r($bug->batchChangeBranchTest($bugIDList2, $branchList2[0], $bugIDList2[0])) && p() && e('0'); // 修改分支为主干 未发生变化
|
||||
r($bug->batchChangeBranchTest($bugIDList2, $branchList2[1], $bugIDList2[1])) && p('0:field,old,new') && e('branch,0,9'); // 修改分支为分支9
|
||||
r($bug->batchChangeBranchTest($bugIDList2, $branchList2[2], $bugIDList2[2])) && p('0:field,old,new') && e('branch,9,10'); // 修改分支为分支10
|
||||
r($bug->batchChangeBranchTest($bugIDList3, $branchList3[0], $bugIDList3[0])) && p() && e('0'); // 修改分支为主干 未发生变化
|
||||
r($bug->batchChangeBranchTest($bugIDList3, $branchList3[1], $bugIDList3[1])) && p('0:field,old,new') && e('branch,0,7'); // 修改分支为分支7
|
||||
r($bug->batchChangeBranchTest($bugIDList3, $branchList3[2], $bugIDList3[2])) && p('0:field,old,new') && e('branch,7,8'); // 修改分支为分支8
|
||||
r($bug->batchChangeBranchTest($bugIDList4, $branchList4[0], $bugIDList4[0])) && p() && e('0'); // 修改分支为主干 未发生变化
|
||||
r($bug->batchChangeBranchTest($bugIDList4, $branchList4[1], $bugIDList4[1])) && p('0:field,old,new') && e('branch,0,37'); // 修改分支为分支37
|
||||
r($bug->batchChangeBranchTest($bugIDList4, $branchList4[2], $bugIDList4[2])) && p('0:field,old,new') && e('branch,37,38'); // 修改分支为分支38
|
||||
system("./ztest init");
|
||||
24
test/model/bug/batchconfirm.php
Executable file
24
test/model/bug/batchconfirm.php
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/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->batchConfirm();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
批量确认1 3 4 51 81 >> ,1,1,1,1,1
|
||||
批量确认2 7 >> ,1,1
|
||||
*/
|
||||
|
||||
$bugIDlist1 = array('1','3','4','51','81');
|
||||
|
||||
$bugIDlist2 = array('2', '7');
|
||||
|
||||
$bug = new bugTest();
|
||||
r($bug->batchConfirmTest($bugIDlist1)) && p() && e(',1,1,1,1,1'); // 批量确认1 3 4 51 81
|
||||
r($bug->batchConfirmTest($bugIDlist2)) && p() && e(',1,1'); // 批量确认2 7
|
||||
system("./ztest init");
|
||||
35
test/model/bug/confirm.php
Executable file
35
test/model/bug/confirm.php
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/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->confirm();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
确认指派人变化的bug >> assignedTo,admin,user92;confirmed,0,1
|
||||
确认类型变化的bug >> type,install,codeerror;confirmed,0,1
|
||||
确认已确认的bug >> 0
|
||||
确认优先级变化的bug >> status,resolved,active;pri,3,2
|
||||
确认bug >> status,closed,active
|
||||
|
||||
*/
|
||||
|
||||
$bugIDlist = array('1','3','4','51','81');
|
||||
|
||||
$bug1 = array('assignedTo' => 'user92', 'status' => 'active', 'type' => 'codeerror', 'pri' => '1');
|
||||
$bug3 = array('assignedTo' => 'admin' , 'status' => 'active', 'type' => 'codeerror', 'pri' => '3');
|
||||
$bug4 = array('assignedTo' => 'admin' , 'status' => 'active', 'type' => 'security', 'pri' => '4');
|
||||
$bug51 = array('assignedTo' => 'dev1' , 'status' => 'active', 'type' => 'standard', 'pri' => '2');
|
||||
$bug81 = array('assignedTo' => 'test1' , 'status' => 'active', 'type' => 'others', 'pri' => '1');
|
||||
|
||||
$bug = new bugTest();
|
||||
r($bug->confirmTest($bugIDlist[0],$bug1)) && p('0:field,old,new;1:field,old,new') && e('assignedTo,admin,user92'); // 确认指派人变化的bug
|
||||
r($bug->confirmTest($bugIDlist[1],$bug3)) && p('0:field,old,new;1:field,old,new') && e('assignedTo,admin,user94'); // 确认类型变化的bug
|
||||
r($bug->confirmTest($bugIDlist[2],$bug4)) && p('0:field,old,new') && e('assignedTo,admin,user95'); // 确认已确认的bug
|
||||
r($bug->confirmTest($bugIDlist[3],$bug51)) && p('0:field,old,new;1:field,old,new') && e('assignedTo,dev1,user96'); // 确认优先级变化的bug
|
||||
r($bug->confirmTest($bugIDlist[4],$bug81)) && p('0:field,old,new') && e('assignedTo,test1,user97'); // 确认bug
|
||||
system("./ztest init");
|
||||
49
test/model/bug/resolve.php
Executable file
49
test/model/bug/resolve.php
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/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->resolve();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
解决原因为设计如此 指派人变化的bug >> resolvedBuild,,trunk;resolution,,bydesign
|
||||
不填解决原因的bug >> 『解决方案』不能为空。
|
||||
解决原因为重复Bug 不填bugID的bug >> 『重复ID』不能为空。
|
||||
解决原因为重复Bug 填bugID的bug >> duplicateBug,0,1;status,active,resolved
|
||||
解决原因为外部原因的bug >> resolvedBuild,,trunk;resolution,,external
|
||||
解决原因为已解决的bug >> resolvedBuild,,trunk;resolution,,fixed
|
||||
解决原因为无法重现的bug >> resolvedBuild,,trunk;resolution,,notrepro
|
||||
解决原因为延期处理的bug >> resolvedBuild,,trunk;resolution,,postponed
|
||||
解决原因为不予解决的bug >> resolvedBuild,,trunk;resolution,,willnotfix
|
||||
解决已解决的bug >> resolvedBuild,,trunk;confirmed,0,1
|
||||
|
||||
*/
|
||||
|
||||
$bugIDList = array('1','2','3','4', '5', '6', '7','51',);
|
||||
|
||||
$bug1 = array('assignedTo' => 'user92', 'resolution' => 'bydesign');
|
||||
$bug2 = array('assignedTo' => 'admin', 'resolution' => 'duplicate');
|
||||
$bug2AB = array('assignedTo' => 'admin', 'resolution' => 'duplicate', 'duplicateBug' => '1');
|
||||
$bug3 = array('assignedTo' => 'admin', 'resolution' => 'external');
|
||||
$bug4 = array('assignedTo' => 'admin', 'resolution' => 'fixed');
|
||||
$bug5 = array('assignedTo' => 'admin', 'resolution' => 'notrepro');
|
||||
$bug6 = array('assignedTo' => 'admin', 'resolution' => 'postponed');
|
||||
$bug7 = array('assignedTo' => 'admin', 'resolution' => 'willnotfix');
|
||||
$bug51 = array('assignedTo' => 'user96', 'resolution' => 'bydesign');
|
||||
|
||||
$bug = new bugTest();
|
||||
r($bug->resolveTest($bugIDList[0],$bug1)) && p('0:field,old,new;4:field,old,new') && e('resolvedBuild,,trunk;resolution,,bydesign'); // 解决原因为设计如此 指派人变化的bug
|
||||
r($bug->resolveTest($bugIDList[0])) && p('resolution:0') && e('『解决方案』不能为空。'); // 不填解决原因的bug
|
||||
r($bug->resolveTest($bugIDList[1],$bug2)) && p('duplicateBug:0') && e('『重复ID』不能为空。'); // 解决原因为重复Bug 不填bugID的bug
|
||||
r($bug->resolveTest($bugIDList[1],$bug2AB)) && p('0:field,old,new;3:field,old,new') && e('duplicateBug,0,1;status,active,resolved'); // 解决原因为重复Bug 填bugID的bug
|
||||
r($bug->resolveTest($bugIDList[2],$bug3)) && p('0:field,old,new;3:field,old,new') && e('resolvedBuild,,trunk;resolution,,external'); // 解决原因为外部原因的bug
|
||||
r($bug->resolveTest($bugIDList[3],$bug4)) && p('0:field,old,new;3:field,old,new') && e('resolvedBuild,,trunk;resolution,,fixed'); // 解决原因为已解决的bug
|
||||
r($bug->resolveTest($bugIDList[4],$bug5)) && p('0:field,old,new;3:field,old,new') && e('resolvedBuild,,trunk;resolution,,notrepro'); // 解决原因为无法重现的bug
|
||||
r($bug->resolveTest($bugIDList[5],$bug6)) && p('0:field,old,new;3:field,old,new') && e('resolvedBuild,,trunk;resolution,,postponed'); // 解决原因为延期处理的bug
|
||||
r($bug->resolveTest($bugIDList[6],$bug7)) && p('0:field,old,new;3:field,old,new') && e('resolvedBuild,,trunk;resolution,,willnotfix'); // 解决原因为不予解决的bug
|
||||
r($bug->resolveTest($bugIDList[7],$bug51)) && p('0:field,old,new;3:field,old,new') && e('resolvedBuild,,trunk;confirmed,0,1'); // 解决已解决的bug
|
||||
system("./ztest init");
|
||||
Reference in New Issue
Block a user