* Add bugModel-createBuild and its unit test, and add comment.
This commit is contained in:
+44
-27
@@ -854,6 +854,7 @@ class bugModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 解决一个bug。
|
||||
* Resolve a bug.
|
||||
*
|
||||
* @param object $bugID
|
||||
@@ -869,34 +870,8 @@ class bugModel extends model
|
||||
/* Can create build when resolving bug. */
|
||||
if(!empty($bug->createBuild))
|
||||
{
|
||||
$this->lang->build->name = $this->lang->bug->placeholder->newBuildName;
|
||||
|
||||
/* Check required fields. */
|
||||
$this->bugTao->checkRequired4Resolve($bug, $oldBug->execution);
|
||||
$this->createBuild($bug, $oldBug);
|
||||
if(dao::isError()) return false;
|
||||
|
||||
/* Construct build data. */
|
||||
$buildData = new stdclass();
|
||||
$buildData->product = (int)$oldBug->product;
|
||||
$buildData->branch = (int)$oldBug->branch;
|
||||
$buildData->project = $this->dao->select('project')->from(TABLE_EXECUTION)->where('id')->eq($bug->buildExecution)->fetch('project');
|
||||
$buildData->execution = $bug->buildExecution;
|
||||
$buildData->name = $bug->buildName;
|
||||
$buildData->date = date('Y-m-d');
|
||||
$buildData->builder = $this->app->user->account;
|
||||
$buildData->createdBy = $this->app->user->account;
|
||||
$buildData->createdDate = helper::now();
|
||||
|
||||
/* Create a build. */
|
||||
$this->dao->insert(TABLE_BUILD)->data($buildData)->autoCheck()
|
||||
->check('name', 'unique', "product = {$buildData->product} AND branch = {$buildData->branch} AND deleted = '0'")
|
||||
->exec();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
/* Get build id, and record log. */
|
||||
$buildID = $this->dao->lastInsertID();
|
||||
$this->loadModel('action')->create('build', $buildID, 'opened');
|
||||
$bug->resolvedBuild = $buildID;
|
||||
}
|
||||
|
||||
/* Update bug. */
|
||||
@@ -936,6 +911,48 @@ class bugModel extends model
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 在解决bug的时候创建一个版本。
|
||||
* Create build when resolving a bug.
|
||||
*
|
||||
* @param object $bug
|
||||
* @param object $oldBug
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function createBuild(object $bug, object $oldBug): bool
|
||||
{
|
||||
/* Check required fields. */
|
||||
$this->bugTao->checkRequired4Resolve($bug, $oldBug->execution);
|
||||
if(dao::isError()) return false;
|
||||
|
||||
/* Construct build data. */
|
||||
$buildData = new stdclass();
|
||||
$buildData->product = (int)$oldBug->product;
|
||||
$buildData->branch = (int)$oldBug->branch;
|
||||
$buildData->project = $this->dao->select('project')->from(TABLE_EXECUTION)->where('id')->eq($bug->buildExecution)->fetch('project');
|
||||
$buildData->execution = $bug->buildExecution;
|
||||
$buildData->name = $bug->buildName;
|
||||
$buildData->date = date('Y-m-d');
|
||||
$buildData->builder = $this->app->user->account;
|
||||
$buildData->createdBy = $this->app->user->account;
|
||||
$buildData->createdDate = helper::now();
|
||||
|
||||
/* Create a build. */
|
||||
$this->lang->build->name = $this->lang->bug->placeholder->newBuildName;
|
||||
$this->dao->insert(TABLE_BUILD)->data($buildData)->autoCheck()
|
||||
->check('name', 'unique', "product = {$buildData->product} AND branch = {$buildData->branch} AND deleted = '0'")
|
||||
->exec();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
/* Get build id, and record log. */
|
||||
$buildID = $this->dao->lastInsertID();
|
||||
$this->loadModel('action')->create('build', $buildID, 'opened');
|
||||
$bug->resolvedBuild = $buildID;
|
||||
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch change branch.
|
||||
*
|
||||
|
||||
@@ -2219,4 +2219,35 @@ class bugTest
|
||||
return 'no error';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试在解决bug的时候创建版本。
|
||||
* Test create build when resolving a bug.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function createBuildTest(object $bug, int $bugID)
|
||||
{
|
||||
global $tester;
|
||||
$oldBug = $tester->dao->findByID($bugID)->from(TABLE_BUG)->fetch();
|
||||
$this->objectModel->createBuild($bug, $oldBug);
|
||||
|
||||
if(dao::isError())
|
||||
{
|
||||
$errors = dao::getError();
|
||||
$return = '';
|
||||
foreach($errors as $key => $value)
|
||||
{
|
||||
if(is_string($value)) $return .= "{$value}";
|
||||
if(is_array($value)) $return .= implode('', $value);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$build = $tester->dao->findByID($bug->resolvedBuild)->from(TABLE_BUILD)->fetch();
|
||||
return $build;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+91
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/bug.class.php';
|
||||
|
||||
zdTable('project')->config('project_createbuild')->gen(2);
|
||||
zdTable('bug')->config('bug_createbuild')->gen(10);
|
||||
zdTable('user')->gen(1);
|
||||
zdTable('build')->gen(1);
|
||||
zdTable('action')->gen(1);
|
||||
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=bugTao->createBuild();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 测试解决版本执行11 解决方案为设计如此的时候创建一个版本属性name @bug新建的版本1
|
||||
|
||||
- 测试解决版本执行12 解决方案为设计如此的时候创建一个版本属性name @bug新建的版本2
|
||||
|
||||
- 测试解决版本执行11 解决方案为重复BUG 重复bugID1的时候创建一个版本属性name @bug新建的版本3
|
||||
|
||||
- 测试解决版本执行11 解决方案为重复BUG 重复bugID1的时候创建一个版本属性name @bug新建的版本4
|
||||
|
||||
- 测试解决版本执行11 解决方案为设计如此的时候创建一个名称为空的版本 @『新版本名称』不能为空。
|
||||
|
||||
- 测试解决版本执行12 解决方案为设计如此的时候创建一个版本执行为空的版本 @『所属看板』不能为空。
|
||||
|
||||
- 测试解决版本执行11 解决方案为设计如此的时候创建一个版本执行为空的版本 @『所属执行』不能为空。
|
||||
|
||||
- 测试解决版本执行11 解决方案为重复BUG 重复bugID为空的时候创建一个名称为空的版本 @『重复Bug』不能为空。
|
||||
|
||||
- 测试解决bugID 11 解决方案为设计如此的时候创建一个同名版本 @『新版本名称』已经有『bug新建的版本1』这条记录了。如果您确定该记录已删除,请到后台-系统-数据-回收站还原。
|
||||
|
||||
*/
|
||||
|
||||
$bugIdList = array(1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
|
||||
$bydesignBug1 = new stdclass();
|
||||
$bydesignBug1->buildExecution = 11;
|
||||
$bydesignBug1->buildName = 'bug新建的版本1';
|
||||
$bydesignBug1->resolution = 'bydesign';
|
||||
|
||||
$bydesignBug2 = new stdclass();
|
||||
$bydesignBug2->buildExecution = 12;
|
||||
$bydesignBug2->buildName = 'bug新建的版本2';
|
||||
$bydesignBug2->resolution = 'bydesign';
|
||||
|
||||
$duplicateBug1 = new stdclass();
|
||||
$duplicateBug1->buildExecution = 11;
|
||||
$duplicateBug1->buildName = 'bug新建的版本3';
|
||||
$duplicateBug1->resolution = 'duplicate';
|
||||
$duplicateBug1->duplicateBug = 1;
|
||||
|
||||
$duplicateBug2 = new stdclass();
|
||||
$duplicateBug2->buildExecution = 12;
|
||||
$duplicateBug2->buildName = 'bug新建的版本4';
|
||||
$duplicateBug2->resolution = 'duplicate';
|
||||
$duplicateBug2->duplicateBug = 1;
|
||||
|
||||
$emptyBuildName = new stdclass();
|
||||
$emptyBuildName->buildExecution = 11;
|
||||
$emptyBuildName->buildName = '';
|
||||
$emptyBuildName->resolution = 'bydesign';
|
||||
|
||||
$emptyBuildExecution = new stdclass();
|
||||
$emptyBuildExecution->buildExecution = 0;
|
||||
$emptyBuildExecution->buildName = 'bug新建的版本2';
|
||||
$emptyBuildExecution->resolution = 'bydesign';
|
||||
|
||||
$emptyDupicateBug = new stdclass();
|
||||
$emptyDupicateBug->buildExecution = 11;
|
||||
$emptyDupicateBug->buildName = 'bug新建的版本2';
|
||||
$emptyDupicateBug->resolution = 'duplicate';
|
||||
$emptyDupicateBug->duplicateBug = 0;
|
||||
|
||||
$bug = new bugTest();
|
||||
|
||||
r($bug->createBuildTest($bydesignBug1, $bugIdList[0])) && p('name') && e('bug新建的版本1'); // 测试解决版本执行11 解决方案为设计如此的时候创建一个版本
|
||||
r($bug->createBuildTest($bydesignBug2, $bugIdList[1])) && p('name') && e('bug新建的版本2'); // 测试解决版本执行12 解决方案为设计如此的时候创建一个版本
|
||||
r($bug->createBuildTest($duplicateBug1, $bugIdList[2])) && p('name') && e('bug新建的版本3'); // 测试解决版本执行11 解决方案为重复BUG 重复bugID1的时候创建一个版本
|
||||
r($bug->createBuildTest($duplicateBug2, $bugIdList[3])) && p('name') && e('bug新建的版本4'); // 测试解决版本执行11 解决方案为重复BUG 重复bugID1的时候创建一个版本
|
||||
r($bug->createBuildTest($emptyBuildName, $bugIdList[4])) && p() && e('『新版本名称』不能为空。'); // 测试解决版本执行11 解决方案为设计如此的时候创建一个名称为空的版本
|
||||
r($bug->createBuildTest($emptyBuildExecution, $bugIdList[5])) && p() && e('『所属看板』不能为空。'); // 测试解决版本执行12 解决方案为设计如此的时候创建一个版本执行为空的版本
|
||||
r($bug->createBuildTest($emptyBuildExecution, $bugIdList[6])) && p() && e('『所属执行』不能为空。'); // 测试解决版本执行11 解决方案为设计如此的时候创建一个版本执行为空的版本
|
||||
r($bug->createBuildTest($emptyDupicateBug, $bugIdList[7])) && p() && e('『重复Bug』不能为空。'); // 测试解决版本执行11 解决方案为重复BUG 重复bugID为空的时候创建一个名称为空的版本
|
||||
|
||||
r($bug->createBuildTest($bydesignBug1, $bugIdList[0])) && p() && e('『新版本名称』已经有『bug新建的版本1』这条记录了。如果您确定该记录已删除,请到后台-系统-数据-回收站还原。'); // 测试解决bugID 11 解决方案为设计如此的时候创建一个同名版本
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
title: zt_bug
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: execution
|
||||
range: "11,12"
|
||||
...
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
title: zt_project
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: model
|
||||
range: "[]"
|
||||
- field: type
|
||||
range: scrum,kanban
|
||||
...
|
||||
|
||||
+4
-2
@@ -1604,7 +1604,8 @@ class bugZen extends bug
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare to resolve a bug.
|
||||
* 为解决bug构造bug数据。
|
||||
* Build bug for resolving a bug.
|
||||
*
|
||||
* @param object $oldBug
|
||||
* @param int $uid
|
||||
@@ -1615,7 +1616,8 @@ class bugZen extends bug
|
||||
{
|
||||
$bug = form::data($this->config->bug->form->resolve)
|
||||
->setDefault('assignedTo', $oldBug->openedBy)
|
||||
->add('id', (int)$oldBug->id)
|
||||
->add('id', $oldBug->id)
|
||||
->add('execution', $oldBug->execution)
|
||||
->add('status', 'resolved')
|
||||
->add('confirmed', 1)
|
||||
->removeIF($this->post->resolution != 'duplicate', 'duplicateBug')
|
||||
|
||||
Reference in New Issue
Block a user