diff --git a/module/bug/control.php b/module/bug/control.php
index dafb982734..d41f598d30 100755
--- a/module/bug/control.php
+++ b/module/bug/control.php
@@ -269,10 +269,20 @@ class bug extends control
$bugs = $this->bugZen->buildBugsForBatchCreate($productID, $branch, $this->session->bugImagesFile);
/* Batch create bugs. */
- $actions = $this->bug->batchCreate($productID, $branch, $extra);
+ $actions = $this->bug->batchCreate($productID, $branch, $output, $this->post->uploadImage, $this->session->bugImagesFile);
helper::setcookie('bugModule', 0, 0);
+ /* Remove upload image file and session. */
+ if(!empty($this->post->uploadImage) and !empty($this->session->bugImagesFile))
+ {
+ $classFile = $this->app->loadClass('zfile');
+ $file = current($_SESSION['bugImagesFile']);
+ $realPath = dirname($file['realpath']);
+ if(is_dir($realPath)) $classFile->removeDir($realPath);
+ unset($_SESSION['bugImagesFile']);
+ }
+
$response = $this->bugZen->responseAfterBatchCreate($productID, $branch, $executionID, $actions);
return $this->send($response);
}
diff --git a/module/bug/model.php b/module/bug/model.php
index 313707fd24..1be0d49e86 100644
--- a/module/bug/model.php
+++ b/module/bug/model.php
@@ -68,167 +68,39 @@ class bugModel extends model
}
/**
- * Batch create
+ * 批量创建bug
+ * Batch create bugs.
*
- * @param int $productID
- * @param int $branch
- * @param string $extra
+ * @param int $productID
+ * @param array $extra
+ * @param array|bool $extra
* @access public
- * @return void
+ * @return array
*/
- public function batchCreate($productID, $branch = 0, $extra = '')
+ public function batchCreate(array $bugs, int $productID, array $output = array(), array|bool $uploadImages = false, array|bool $bugImagesFiles = false)
{
- $extra = str_replace(array(',', ' '), array('&', ''), $extra);
- parse_str($extra, $output);
-
/* Load module and init vars. */
$this->loadModel('action');
- $this->loadModel('kanban');
- $branch = (int)$branch;
- $productID = (int)$productID;
- $now = helper::now();
- $actions = array();
- $data = fixer::input('post')->get();
+ if(!empty($uploadImages)) $this->loadModel('file');
- /* Remove the bug with the same name within the specified time. */
- $result = $this->loadModel('common')->removeDuplicate('bug', $data, "product={$productID}");
- $data = $result['data'];
+ /* Check bugs. */
+ $bugs = $this->bugTao->checkBugsForBatchCreate($bugs, $productID);
+ if(dao::isError()) return false;
- /* Get pairs(moduleID => moduleOwner) for bug. */
- $stmt = $this->dbh->query($this->loadModel('tree')->buildMenuQuery($productID, 'bug', $startModuleID = 0, $branch));
- $moduleOwners = array();
- while($module = $stmt->fetch()) $moduleOwners[$module->id] = $module->owner;
-
- /* Construct data. */
- $module = 0;
- $project = 0;
- $execution = 0;
- $type = '';
- $pri = 0;
- foreach($data->title as $i => $title)
- {
- if(empty($title) and $this->common->checkValidRow('bug', $data, $i))
- {
- dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->bug->title);
- return false;
- }
-
- $oses = array_filter($data->oses[$i]);
- $browsers = array_filter($data->browsers[$i]);
-
- if($data->modules[$i] != 'ditto') $module = (int)$data->modules[$i];
- if($data->projects[$i] != 'ditto') $project = (int)$data->projects[$i];
- if($data->executions[$i] != 'ditto') $execution = (int)$data->executions[$i];
- if($data->types[$i] != 'ditto') $type = $data->types[$i];
- if($data->pris[$i] != 'ditto') $pri = $data->pris[$i];
-
- $data->modules[$i] = (int)$module;
- $data->projects[$i] = (int)$project;
- $data->executions[$i] = (int)$execution;
- $data->types[$i] = $type;
- $data->pris[$i] = $pri;
- $data->oses[$i] = implode(',', $oses);
- $data->browsers[$i] = implode(',', $browsers);
- }
-
- /* Get bug data. */
- if(isset($data->uploadImage)) $this->loadModel('file');
- $extendFields = $this->getFlowExtendFields();
- $bugs = array();
- foreach($data->title as $i => $title)
- {
- $title = trim($title);
- if(empty($title)) continue;
-
- $bug = new stdClass();
- $bug->openedBy = $this->app->user->account;
- $bug->openedDate = $now;
- $bug->product = (int)$productID;
- $bug->branch = isset($data->branches) ? (int)$data->branches[$i] : 0;
- $bug->module = (int)$data->modules[$i];
- $bug->project = (int)$data->projects[$i];
- $bug->execution = (int)$data->executions[$i];
- $bug->openedBuild = isset($data->openedBuilds) ? implode(',', $data->openedBuilds[$i]) : '';
- $bug->color = $data->color[$i];
- $bug->title = $title;
- $bug->deadline = $data->deadlines[$i];
- $bug->steps = nl2br($data->stepses[$i]);
- $bug->type = $data->types[$i];
- $bug->pri = $data->pris[$i];
- $bug->severity = $data->severities[$i];
- $bug->os = $data->oses[$i];
- $bug->browser = $data->browsers[$i];
- $bug->keywords = $data->keywords[$i];
-
- if(isset($data->lanes[$i])) $bug->laneID = $data->lanes[$i];
-
- /* Assign the bug to the person in charge of the module. */
- if(!empty($moduleOwners[$bug->module]))
- {
- $bug->assignedTo = $moduleOwners[$bug->module];
- $bug->assignedDate = $now;
- }
-
- /* Get extend fields. */
- foreach($extendFields as $extendField)
- {
- $bug->{$extendField->field} = $this->post->{$extendField->field}[$i];
- if(is_array($bug->{$extendField->field})) $bug->{$extendField->field} = implode(',', $bug->{$extendField->field});
-
- $bug->{$extendField->field} = htmlSpecialString($bug->{$extendField->field});
- }
-
- /* Check required fields. */
- foreach(explode(',', $this->config->bug->create->requiredFields) as $field)
- {
- $field = trim($field);
- if($field and empty($bug->$field))
- {
- dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->bug->$field);
- return false;
- }
- }
-
- $bugs[$i] = $bug;
- }
-
- foreach($bugs as $i => $bug)
+ $actions = array();
+ foreach($bugs as $index => $bug)
{
/* Get lane id, remove laneID from bug. */
- $laneID = isset($output['laneID']) ? $output['laneID'] : 0;
+ $laneID = zget($output, 'laneID', 0);
if(isset($bug->laneID))
{
$laneID = $bug->laneID;
unset($bug->laneID);
}
- /* When the bug is created by uploading an image, add the image to the step of the bug. */
- if(!empty($data->uploadImage[$i]))
- {
- $fileName = $data->uploadImage[$i];
- $file = $this->session->bugImagesFile[$fileName];
+ $uploadImage = !empty($uploadImages[$index]) ? $uploadImages[$index] : '';
- $realPath = $file['realpath'];
- unset($file['realpath']);
- if(rename($realPath, $this->file->savePath . $this->file->getSaveName($file['pathname'])))
- {
- if(in_array($file['extension'], $this->config->file->imageExtensions))
- {
- $file['addedBy'] = $this->app->user->account;
- $file['addedDate'] = $now;
- $this->dao->insert(TABLE_FILE)->data($file)->exec();
-
- $fileID = $this->dao->lastInsertID();
- $bug->steps .= '
';
- }
- }
- else
- {
- unset($file);
- }
- }
-
- if($this->lang->navGroup->bug != 'qa') $bug->project = $this->session->project;
+ $file = $this->processImageForBatchCreate($bug, $uploadImage, $bugImagesFiles);
/* Create a bug. */
$this->dao->insert(TABLE_BUG)->data($bug)
@@ -238,51 +110,18 @@ class bugModel extends model
->exec();
if(dao::isError()) return false;
- $bugID = $this->dao->lastInsertID();
+ $bug->id = $this->dao->lastInsertID();
- $this->executeHooks($bugID);
-
- /* If bug has the execution, update kanban data. */
- if($bug->execution)
- {
- $columnID = $this->kanban->getColumnIDByLaneID($laneID, 'unconfirmed');
- if(empty($columnID)) $columnID = isset($output['columnID']) ? $output['columnID'] : 0;
-
- if(!empty($laneID) and !empty($columnID)) $this->kanban->addKanbanCell($bug->execution, $laneID, $columnID, 'bug', $bugID);
- if(empty($laneID) or empty($columnID)) $this->kanban->updateLane($bug->execution, 'bug');
-
- }
-
- $this->loadModel('score')->create('bug', 'create', $bugID);
-
- /* When the bug is created by uploading the image, add the image to the file of the bug. */
- if(!empty($data->uploadImage[$i]) and !empty($file))
- {
- $file['objectType'] = 'bug';
- $file['objectID'] = $bugID;
- $file['addedBy'] = $this->app->user->account;
- $file['addedDate'] = $now;
- $this->dao->insert(TABLE_FILE)->data($file)->exec();
- unset($file);
- }
+ /* Processing other operations after batch creation. */
+ $actions[$bug->id] = $this->afterBatchCreate($bug, $laneID, $output, $uploadImage, $file);
if(dao::isError())
{
- dao::$errors['message'][] = 'bug#' . ($i) . dao::getError(true);
+ dao::$errors['message'][] = 'bug#' . ($index) . dao::getError(true);
return false;
}
- $actions[$bugID] = $this->action->create('bug', $bugID, 'Opened');
}
- /* Remove upload image file and session. */
- if(!empty($data->uploadImage) and $this->session->bugImagesFile)
- {
- $classFile = $this->app->loadClass('zfile');
- $file = current($_SESSION['bugImagesFile']);
- $realPath = dirname($file['realpath']);
- if(is_dir($realPath)) $classFile->removeDir($realPath);
- unset($_SESSION['bugImagesFile']);
- }
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchCreate');
return $actions;
}
@@ -3140,4 +2979,133 @@ class bugModel extends model
return $index;
}
+
+ /**
+ * 检查批量创建的bug的数据。
+ * Check the batch created bugs.
+ *
+ * @param array $bugs
+ * @param int $productID
+ * @access protected
+ * @return array
+ */
+ protected function checkBugsForBatchCreate(array $bugs, int $productID): array
+ {
+ $this->loadModel('common');
+
+ /* Remove the bug with the same name within the specified time. */
+ foreach($bugs as $index => $bug)
+ {
+ $result = $this->common->removeDuplicate('bug', $bug, "product={$productID}");
+ if(zget($result, 'stop', false) !== false)
+ {
+ unset($bugs[$index]);
+ continue;
+ }
+
+ /* If the bug is not valid data, unset it.*/
+ if($this->common->checkValidRow('bug', $bug, $index))
+ {
+ unset($bugs[$index]);
+ continue;
+ }
+
+ /* Title cannot be empty. */
+ if(empty($bug->title)) dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->bug->title);
+
+ /* Check required fields. */
+ foreach(explode(',', $this->config->bug->create->requiredFields) as $field)
+ {
+ $field = trim($field);
+ if($field and empty($bug->$field) and $field != 'title') dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->bug->$field);
+ }
+ }
+
+ return $bugs;
+ }
+
+ /**
+ * 批量创建bug前处理上传图片。
+ * Before batch creating bugs, process the uploaded images.
+ *
+ * @param object $bug
+ * @param string $uploadImage
+ * @param array|bool $bugImagesFiles
+ * @access protected
+ * @return array|false
+ */
+ protected function processImageForBatchCreate(object $bug, string $uploadImage, array|bool $bugImagesFiles): array|false
+ {
+ /* When the bug is created by uploading an image, add the image to the step of the bug. */
+ if(!empty($uploadImage))
+ {
+ $this->loadModel('file');
+
+ $file = $bugImagesFiles[$uploadImage];
+ $realPath = $file['realpath'];
+
+ if(rename($realPath, $this->file->savePath . $this->file->getSaveName($file['pathname'])))
+ {
+ if(in_array($file['extension'], $this->config->file->imageExtensions))
+ {
+ $file['addedBy'] = $this->app->user->account;
+ $file['addedDate'] = helper::now();
+ $this->dao->insert(TABLE_FILE)->data($file, 'realpath')->exec();
+
+ $fileID = $this->dao->lastInsertID();
+ $bug->steps .= '
';
+ }
+ }
+ else
+ {
+ unset($file);
+ }
+ }
+
+ return !empty($file) ? $file : false;
+ }
+
+ /**
+ * 批量创建bug后的其他处理。
+ * Processing after batch creation of bug.
+ *
+ * @param object $bug
+ * @param int $laneID
+ * @param array $output
+ * @param string $uploadImage
+ * @param array|bool $file
+ * @access protected
+ * @return int|bool
+ */
+ protected function afterBatchCreate(object $bug, int $laneID, array $output, string $uploadImage, array|bool $file): int|bool
+ {
+ /* Record log. */
+ $actionID = $this->loadModel('action')->create('bug', $bug->id, 'Opened');
+
+ $this->loadModel('score')->create('bug', 'create', $bug->id);
+
+ $this->executeHooks($bug->id);
+
+ /* If bug has the execution, update kanban data. */
+ if($bug->execution)
+ {
+ $columnID = $this->loadModel('kanban')->getColumnIDByLaneID($laneID, 'unconfirmed');
+ if(empty($columnID)) $columnID = zget($output, 'columnID', 0);
+
+ if(!empty($laneID) and !empty($columnID)) $this->kanban->addKanbanCell($bug->execution, $laneID, $columnID, 'bug', $bug->id);
+ if(empty($laneID) or empty($columnID)) $this->kanban->updateLane($bug->execution, 'bug');
+ }
+
+ /* When the bug is created by uploading the image, add the image to the file of the bug. */
+ if(!empty($uploadImage) and !empty($file))
+ {
+ $file['objectType'] = 'bug';
+ $file['objectID'] = $bug->id;
+ $file['addedBy'] = $this->app->user->account;
+ $file['addedDate'] = helper::now();
+ $this->dao->insert(TABLE_FILE)->data($file, 'realpath')->exec();
+ unset($file);
+ }
+ return $actionID;
+ }
}
diff --git a/module/bug/test/bug.class.php b/module/bug/test/bug.class.php
index d261f07ba7..26069403c5 100644
--- a/module/bug/test/bug.class.php
+++ b/module/bug/test/bug.class.php
@@ -46,20 +46,25 @@ class bugTest
}
/**
+ * 测试批量创建bug。
* Test batch create bugs.
*
- * @param int $productID
- * @param array $param
+ * @param int $productID
+ * @param array $param
+ * @param array $output
+ * @param array|false $uploadImages
+ * @param array|false $bugImagesFiles
* @access public
- * @return object
+ * @return array|object|string
*/
- public function batchCreateObject($productID, $param = array())
+ public function batchCreateObject(int $productID, array $param = array(), array $output = array(), array|bool $uploadImages = false, array|bool $bugImagesFiles = false): array|object|string
{
+ $_SERVER['HTTP_HOST'] = '';
+
$modules = array('0', '0', '0');
- $executions = array('101', '101', '0');
+ $executions = array('11', '11', '11');
$openedBuilds = array('', '', '');
- $title = array('', '', '');
- $deadlines = array('0000-00-00', '0000-00-00', '0000-00-00');
+ $deadlines = array('2023-01-01', '2023-01-01', '2023-01-01');
$stepses = array('', '', '');
$types = array('', '', '');
$severities = array(3, 3, 3);
@@ -69,43 +74,55 @@ class bugTest
$color = array('', '', '');
$keywords = array('', '', '');
- $createFields['modules'] = $modules;
- $createFields['executions'] = $executions;
- $createFields['openedBuilds'] = $openedBuilds;
- $createFields['title'] = $title;
- $createFields['deadlines'] = $deadlines;
- $createFields['stepses'] = $stepses;
- $createFields['types'] = $types;
- $createFields['severities'] = $severities;
- $createFields['oses'] = $oses;
- $createFields['browsers'] = $browsers;
- $createFields['pris'] = $pris;
- $createFields['color'] = $color;
- $createFields['keywords'] = $keywords;
+ $bugs = array();
+ foreach($param['title'] as $index => $title)
+ {
+ $bug = new stdclass();
+ $bug->title = $title;
+ $bug->product = $productID;
+ $bug->module = isset($param['modules']) ? $param['modules'][$index] : $modules[$index];
+ $bug->execution = isset($param['executions']) ? $param['executions'][$index] : $executions[$index];
+ $bug->openedBuild = isset($param['openedBuilds']) ? $param['openedBuilds'][$index] : $openedBuilds[$index];
+ $bug->deadline = isset($param['deadlines']) ? $param['deadlines'][$index] : $deadlines[$index];
+ $bug->steps = isset($param['stepses']) ? $param['stepses'][$index] : $stepses[$index];
+ $bug->type = isset($param['types']) ? $param['types'][$index] : $types[$index];
+ $bug->severity = isset($param['severities']) ? $param['severities'][$index] : $severities[$index];
+ $bug->os = isset($param['oses']) ? $param['oses'][$index] : $oses[$index];
+ $bug->browser = isset($param['browsers']) ? $param['browsers'][$index] : $browsers[$index];
+ $bug->pri = isset($param['pris']) ? $param['pris'][$index] : $pris[$index];
+ $bug->color = isset($param['color']) ? $param['color'][$index] : $color[$index];
+ $bug->keywords = isset($param['keywords']) ? $param['keywords'][$index] : $keywords[$index];
+ if(isset($param['laneID'])) $bug->laneID = $param['laneID'][$index];
+ if(is_array($bug->openedBuild)) $bug->openedBuild = implode(',', $bug->openedBuild);
- foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue;
+ $bugs[] = $bug;
+ }
- foreach($param as $key => $value) $_POST[$key] = $value;
+ $object = $this->objectModel->batchCreate($bugs, $productID, $output, $uploadImages, $bugImagesFiles);
- $object = $this->objectModel->batchCreate($productID);
-
- $bug = array();
+ $bugs = array();
if(is_array($object))
{
foreach($object as $bugID => $actionID)
{
- $bug[] = $this->objectModel->getByID($bugID);
+ $bugs[] = $this->objectModel->getByID($bugID);
}
}
- unset($_POST);
if(dao::isError())
{
- return dao::getError();
+ $return = '';
+ $errors = dao::getError();
+ foreach($errors as $key => $value)
+ {
+ if(is_string($value)) $return .= "{$value}";
+ if(is_array($value)) $return .= implode('', $value);
+ }
+ return $return;
}
else
{
- return empty($bug) ? $object : $bug;
+ return empty($bugs) ? $object : $bugs;
}
}
@@ -2282,4 +2299,115 @@ class bugTest
global $tester;
return $tester->config->bug->dtable->fieldList['actions']['actionsMap'];
}
+
+ /**
+ * 测试检查批量创建的bug的数据。
+ * Test check the batch created bugs.
+ *
+ * @param array $bugs
+ * @param int $productID
+ * @access public
+ * @return array|string
+ */
+ public function checkBugsForBatchCreateTest(array $bugs, int $productID): array|string
+ {
+ $bugs = $this->objectModel->checkBugsForBatchCreate($bugs, $productID);
+
+ $return = '';
+ if(dao::isError())
+ {
+ $errors = dao::getError();
+ foreach($errors as $key => $value)
+ {
+ if(is_string($value)) $return .= "{$value}";
+ if(is_array($value)) $return .= implode('', $value);
+ }
+ return $return;
+ }
+ else
+ {
+ $return = array_keys($bugs);
+ return implode(',', $return);
+ }
+ }
+
+ /**
+ * 测试检查批量创建的bug的数据。
+ * Test check the batch created bugs.
+ *
+ * @param array $bugs
+ * @param string $required
+ * @access public
+ * @return array|string
+ */
+ public function afterBatchCreateTest(int $bugID, int $laneID, array $output, string $uploadImage, array|bool $file): array|string
+ {
+ $_SERVER['HTTP_HOST'] = '';
+
+ global $tester;
+ $bug = $tester->dao->findByID($bugID)->from(TABLE_BUG)->fetch();
+
+ $actionID = $this->objectModel->afterBatchCreate($bug, $laneID, $output, $uploadImage, $file);
+
+ $return = '';
+ if(dao::isError())
+ {
+ $errors = dao::getError();
+ foreach($errors as $key => $value)
+ {
+ if(is_string($value)) $return .= "{$value}";
+ if(is_array($value)) $return .= implode('', $value);
+ }
+ return $return;
+ }
+ else
+ {
+ $fileID = $tester->dao->select('id')->from(TABLE_FILE)->where('objectID')->eq($bugID)->andWhere('objectType')->eq('bug')->fetch('id');
+ $cards = $tester->dao->select('cards')->from(TABLE_KANBANCELL)
+ ->where('kanban')->eq($bug->execution)
+ ->andWhere('lane')->eq($laneID)
+ ->andWhere('column')->eq(zget($output, 'columnID', 0))
+ ->andWhere('type')->eq('bug')
+ ->fetch('cards');
+
+ return "action:{$actionID},file:{$fileID},cards:{$cards}";
+ }
+ }
+
+ /**
+ * 测试批量创建bug前处理上传图片。
+ * Test process the uploaded images before batch creating bugs.
+ *
+ * @param object $bug
+ * @param string $uploadImage
+ * @param array $bugImagesFile
+ * @access public
+ * @return array|string
+ */
+ public function processImageForBatchCreateTest(object $bug, string $uploadImage, array $bugImagesFiles): array|string
+ {
+ $_SERVER['HTTP_HOST'] = '';
+
+ global $tester;
+ $tester->loadModel('file');
+ $tester->file->savePath = $tester->app->tmpRoot;
+
+ $file = $this->objectModel->processImageForBatchCreate($bug, $uploadImage, $bugImagesFiles);
+
+ if(dao::isError())
+ {
+ $return = '';
+ $errors = dao::getError();
+ foreach($errors as $key => $value)
+ {
+ if(is_string($value)) $return .= "{$value}";
+ if(is_array($value)) $return .= implode('', $value);
+ }
+ return $return;
+ }
+ else
+ {
+ return $file;
+ }
+ }
}
diff --git a/module/bug/test/model/afterbatchcreate.php b/module/bug/test/model/afterbatchcreate.php
new file mode 100755
index 0000000000..20ee89dc57
--- /dev/null
+++ b/module/bug/test/model/afterbatchcreate.php
@@ -0,0 +1,51 @@
+#!/usr/bin/env php
+gen(1);
+zdTable('action')->gen(1);
+zdTable('file')->gen(1);
+zdTable('product')->gen(10);
+
+zdTable('bug')->config('bug_afterbatchcreate')->gen(20);
+zdTable('project')->config('project_afterbatchcreate')->gen(1);
+zdTable('kanbanregion')->config('kanbanregion_afterbatchcreate')->gen(1);
+zdTable('kanbanlane')->config('kanbanlane_afterbatchcreate')->gen(1);
+zdTable('kanbancolumn')->config('kanbancolumn_afterbatchcreate')->gen(9);
+zdTable('kanbancell')->config('kanbancell_afterbatchcreate')->gen(9);
+
+su('admin');
+
+/**
+
+title=bugModel->afterBatchCreate();
+cid=1
+pid=1
+
+*/
+
+$bugIdList = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
+$laneIdList = array(0, 1);
+$output = array(array(), array('columnID' => 1));
+$uploadImage = array('', '文件');
+$file = array(false, array('title' => '文件'));
+
+$bug = new bugTest();
+
+r($bug->afterBatchCreateTest($bugIdList[0], $laneIdList[0], $output[0], $uploadImage[0], $file[0])) && p() && e('action:3,file:,cards:'); // 测试进行批量创建bug 1 后的操作 无laneID 无columnID 无uploadImage 无file
+r($bug->afterBatchCreateTest($bugIdList[1], $laneIdList[1], $output[1], $uploadImage[0], $file[0])) && p() && e('action:4,file:,cards:,2,1,3,5,7,9,11,13,15,17,19,'); // 测试进行批量创建bug 2 后的操作 有laneID 无columnID 无uploadImage 无file
+r($bug->afterBatchCreateTest($bugIdList[2], $laneIdList[0], $output[0], $uploadImage[0], $file[0])) && p() && e('action:5,file:,cards:'); // 测试进行批量创建bug 3 后的操作 无laneID 有columnID 无uploadImage 无file
+r($bug->afterBatchCreateTest($bugIdList[3], $laneIdList[1], $output[1], $uploadImage[0], $file[0])) && p() && e('action:6,file:,cards:,4,2,1,3,5,7,9,11,13,15,17,19,'); // 测试进行批量创建bug 4 后的操作 有laneID 有columnID 无uploadImage 无file
+r($bug->afterBatchCreateTest($bugIdList[4], $laneIdList[1], $output[1], $uploadImage[1], $file[0])) && p() && e('action:7,file:,cards:,5,4,2,1,3,5,7,9,11,13,15,17,19,'); // 测试进行批量创建bug 5 后的操作 有laneID 有columnID 有uploadImage 无file
+r($bug->afterBatchCreateTest($bugIdList[5], $laneIdList[1], $output[1], $uploadImage[0], $file[1])) && p() && e('action:8,file:,cards:,6,5,4,2,1,3,5,7,9,11,13,15,17,19,'); // 测试进行批量创建bug 6 后的操作 有laneID 有columnID 无uploadImage 有file
+r($bug->afterBatchCreateTest($bugIdList[6], $laneIdList[1], $output[1], $uploadImage[1], $file[1])) && p() && e('action:9,file:2,cards:,7,6,5,4,2,1,3,5,7,9,11,13,15,17,19,'); // 测试进行批量创建bug 7 后的操作 有laneID 有columnID 有uploadImage 有file
+r($bug->afterBatchCreateTest($bugIdList[7], $laneIdList[1], $output[0], $uploadImage[1], $file[1])) && p() && e('action:10,file:3,cards:'); // 测试进行批量创建bug 8 后的操作 有laneID 无columnID 有uploadImage 有file
+r($bug->afterBatchCreateTest($bugIdList[8], $laneIdList[0], $output[1], $uploadImage[1], $file[1])) && p() && e('action:11,file:4,cards:'); // 测试进行批量创建bug 9 后的操作 无laneID 有columnID 有uploadImage 有file
+r($bug->afterBatchCreateTest($bugIdList[9], $laneIdList[1], $output[0], $uploadImage[1], $file[1])) && p() && e('action:12,file:5,cards:'); // 测试进行批量创建bug 10 后的操作 无laneID 无columnID 有uploadImage 有file
+r($bug->afterBatchCreateTest($bugIdList[10], $laneIdList[1], $output[0], $uploadImage[0], $file[1])) && p() && e('action:13,file:,cards:'); // 测试进行批量创建bug 11 后的操作 有laneID 无columnID 无uploadImage 有file
+r($bug->afterBatchCreateTest($bugIdList[11], $laneIdList[0], $output[1], $uploadImage[0], $file[1])) && p() && e('action:14,file:,cards:'); // 测试进行批量创建bug 12 后的操作 无laneID 有columnID 无uploadImage 有file
+r($bug->afterBatchCreateTest($bugIdList[12], $laneIdList[1], $output[0], $uploadImage[0], $file[1])) && p() && e('action:15,file:,cards:'); // 测试进行批量创建bug 13 后的操作 无laneID 无columnID 无uploadImage 有file
+r($bug->afterBatchCreateTest($bugIdList[13], $laneIdList[1], $output[0], $uploadImage[1], $file[0])) && p() && e('action:16,file:,cards:'); // 测试进行批量创建bug 14 后的操作 有laneID 无columnID 有uploadImage 无file
+r($bug->afterBatchCreateTest($bugIdList[14], $laneIdList[0], $output[1], $uploadImage[1], $file[0])) && p() && e('action:17,file:,cards:'); // 测试进行批量创建bug 15 后的操作 无laneID 有columnID 有uploadImage 无file
+r($bug->afterBatchCreateTest($bugIdList[15], $laneIdList[1], $output[0], $uploadImage[1], $file[0])) && p() && e('action:18,file:,cards:'); // 测试进行批量创建bug 16 后的操作 无laneID 无columnID 有uploadImage 无file
diff --git a/module/bug/test/model/batchcreate.php b/module/bug/test/model/batchcreate.php
index 007670d2bc..d33d1afcd0 100755
--- a/module/bug/test/model/batchcreate.php
+++ b/module/bug/test/model/batchcreate.php
@@ -2,8 +2,50 @@
gen(1);
+zdTable('product')->gen(10);
+zdTable('action')->gen(1);
+
+zdTable('project')->config('project_batchcreate')->gen(1);
+zdTable('kanbanregion')->config('kanbanregion_batchcreate')->gen(1);
+zdTable('kanbanlane')->config('kanbanlane_batchcreate')->gen(1);
+zdTable('kanbancolumn')->config('kanbancolumn_batchcreate')->gen(9);
+zdTable('kanbancell')->config('kanbancell_batchcreate')->gen(9);
+
su('admin');
+function initImage($imagesFiles)
+{
+ foreach($imagesFiles as $bugImagesFile)
+ {
+ if(!empty($bugImagesFile['realpath']) and !is_file($bugImagesFile['realpath']))
+ {
+ $theFile = fopen($bugImagesFile['realpath'], 'w');
+ fclose($theFile);
+ }
+ }
+}
+
+function dropImage($imagesFiles)
+{
+ foreach($imagesFiles as $bugImagesFile)
+ {
+ if(!empty($bugImagesFile['realpath']) and is_file($bugImagesFile['realpath']))
+ {
+ $zfile->removeFile($bugImagesFile['realpath']);
+ }
+ if(!empty($bugImagesFile['pathname']) and is_file($bugImagesFile['pathname']))
+ {
+ $zfile->removeFile($bugImagesFile['pathname']);
+ }
+ if(!empty($bugImagesFile['title']) and is_file($bugImagesFile['title']))
+ {
+ $zfile->removeFile($bugImagesFile['title']);
+ }
+ }
+}
+
/**
title=bugModel->batchCreate();
@@ -21,25 +63,55 @@ pid=1
$productID = 1;
$title = array('批量bug一','批量bug二','批量bug三');
-$openedBuild = array(array('trunk', '3'), array('trunk'), array('1'));
-$type = array('codeerror','ditto','config');
+$openedBuild = array(array('3'), array('trunk'), array('1'));
+$type = array('codeerror','notrepro','config');
$severity = array('3','2','1');
$normal_create1 = array('title' => $title, 'types' => $type, 'openedBuilds' => $openedBuild, 'severity' => $severity);
$title = array('批量bug四','批量bug五','批量bug六');
$normal_create2 = array('title' => $title, 'types' => $type, 'openedBuilds' => $openedBuild, 'severity' => $severity);
+$execution = array(0, 0, 0);
$title = array('批量bug七','批量bug八','批量bug九');
-$normal_create3 = array('title' => $title, 'types' => $type, 'openedBuilds' => $openedBuild, 'severity' => $severity);
+$normal_create3 = array('title' => $title, 'types' => $type, 'openedBuilds' => $openedBuild, 'severity' => $severity, 'executions' => $execution);
+
+$laneIdList = array(1, 2, 3);
+
+$title = array('批量bug十','批量bug十一','批量bug十二');
+$normal_create4 = array('title' => $title, 'types' => $type, 'openedBuilds' => $openedBuild, 'severity' => $severity, 'laneID' => $laneIdList, 'executions' => $execution);
+
+$title = array('批量bug十三','批量bug十四','批量bug十五');
+$normal_create5 = array('title' => $title, 'types' => $type, 'openedBuilds' => $openedBuild, 'severity' => $severity, 'laneID' => $laneIdList);
$title = array('异常一','异常二','异常三');
-$openedBuild = array(array('trunk'), array(''), array('1'));
-$exception_create = array('title' => $title, 'openedBuilds' => $openedBuild);
+$emptyBuild = array(array('trunk'), array(''), array('1'));
+$empty_build_create = array('title' => $title, 'openedBuilds' => $emptyBuild);
+
+$emptyTitle = array('名称','','名称三');
+$empty_title_create = array('title' => $emptyTitle, 'openedBuilds' => $openedBuild);
+
+$output = array(array(), array('laneID' => 1, 'columnID' => 1));
+
+$jpgFile = array();
+$jpgFile['realpath'] = $tester->app->tmpRoot . '1.jpg';
+$jpgFile['pathname'] = '1.jpg';
+$jpgFile['title'] = '1';
+$jpgFile['extension'] = 'jpg';
+
+$bugImagesFiles = array(false, array('jpg' => $jpgFile));
+$uploadImages = array(false, array('jpg'));
+
+initImage($bugImagesFiles[1]);
$bug = new bugTest();
-r($bug->batchCreateObject($productID, $normal_create1)) && p('0:title,openedBuild,type,severity,pri,product,execution') && e('批量bug一,trunk,3,codeerror,3,3,1,101'); // 测试正常批量创建bug1
-r($bug->batchCreateObject($productID, $normal_create2)) && p('1:title,openedBuild,type,severity,pri,product,execution') && e('批量bug五,trunk,codeerror,3,3,1,101'); // 测试正常批量创建bug2
-r($bug->batchCreateObject($productID, $normal_create3)) && p('2:title,openedBuild,type,severity,pri,product,execution') && e('批量bug九,1,config,3,3,1,0'); // 测试正常批量创建bug3
-r($bug->batchCreateObject($productID, $normal_create1)) && p() && e('0'); // 测试短时间内重复批量创建bug
-r($bug->batchCreateObject($productID, $exception_create)) && p('message:0') && e("『影响版本』不能为空。"); // 测试异常创建bug
+r($bug->batchCreateObject($productID, $normal_create1, $output[0], $uploadImages[0], $bugImagesFiles[0])) && p('0:title,openedBuild,type,severity,pri,product,execution') && e('批量bug一,3,codeerror,3,3,1,11'); // 测试正常批量创建bug1
+r($bug->batchCreateObject($productID, $normal_create2, $output[1], $uploadImages[0], $bugImagesFiles[0])) && p('1:title,openedBuild,type,severity,pri,product,execution') && e('批量bug五,trunk,notrepro,3,3,1,11'); // 测试正常批量创建bug2 有output
+r($bug->batchCreateObject($productID, $normal_create3, $output[0], $uploadImages[1], $bugImagesFiles[1])) && p('2:title,openedBuild,type,severity,pri,product,execution') && e('批量bug九,1,config,3,3,1,0'); // 测试正常批量创建bug3 上传图片
+dropImage($bugImagesFiles[1]);
+initImage($bugImagesFiles[1]);
+r($bug->batchCreateObject($productID, $normal_create4, $output[0], $uploadImages[0], $bugImagesFiles[0])) && p('0:title,openedBuild,type,severity,pri,product,execution') && e('批量bug十,3,codeerror,3,3,1,0'); // 测试正常批量创建bug4 bug有laneID
+r($bug->batchCreateObject($productID, $normal_create5, $output[1], $uploadImages[1], $bugImagesFiles[1])) && p('1:title,openedBuild,type,severity,pri,product,execution') && e('批量bug十四,trunk,notrepro,3,3,1,11'); // 测试正常批量创建bug5 有output 上传图片 bug有laneID
+dropImage($bugImagesFiles[1]);
+r($bug->batchCreateObject($productID, $empty_build_create)) && p('') && e("『影响版本』不能为空。"); // 测试创建没有版本的bug
+r($bug->batchCreateObject($productID, $empty_title_create)) && p('') && e("『Bug标题』不能为空。"); // 测试创建没有标题的bug
diff --git a/module/bug/test/model/checkbugsforbatchcreate.php b/module/bug/test/model/checkbugsforbatchcreate.php
new file mode 100755
index 0000000000..9d338bfa6a
--- /dev/null
+++ b/module/bug/test/model/checkbugsforbatchcreate.php
@@ -0,0 +1,101 @@
+#!/usr/bin/env php
+resolve();
+cid=1
+pid=1
+
+*/
+
+$emptyTitle = new stdclass();
+$emptyTitle->title = '';
+$emptyTitle->openedBuild = 1;
+
+$emptyBuild = new stdclass();
+$emptyBuild->title = '111';
+$emptyBuild->openedBuild = 0;
+
+$emptyItem = new stdclass();
+
+$emptyAll = new stdclass();
+$emptyAll->title = '';
+$emptyAll->openedBuild = 0;
+$emptyAll->product = 0;
+$emptyAll->branch = 0;
+$emptyAll->module = 0;
+$emptyAll->project = 0;
+$emptyAll->execution = 0;
+$emptyAll->deadline = '';
+$emptyAll->steps = '';
+$emptyAll->type = '';
+$emptyAll->pri = 0;
+$emptyAll->severity = 0;
+$emptyAll->keywords = '';
+
+$hasTitleBuild = new stdclass();
+$hasTitleBuild->title = '11';
+$hasTitleBuild->openedBuild = 1;
+$hasTitleBuild->product = 0;
+$hasTitleBuild->branch = 0;
+$hasTitleBuild->module = 0;
+$hasTitleBuild->project = 0;
+$hasTitleBuild->execution = 0;
+$hasTitleBuild->deadline = '';
+$hasTitleBuild->steps = '';
+$hasTitleBuild->type = '';
+$hasTitleBuild->pri = 0;
+$hasTitleBuild->severity = 0;
+$hasTitleBuild->keywords = '';
+
+$normal1 = new stdclass();
+$normal1->title = '一个标题';
+$normal1->openedBuild = 1;
+$normal1->product = 1;
+$normal1->branch = 0;
+$normal1->module = 1;
+$normal1->project = 1;
+$normal1->execution = 11;
+$normal1->deadline = '2023-01-01';
+$normal1->steps = '一个步骤';
+$normal1->type = 'codeerror';
+$normal1->pri = 1;
+$normal1->severity = 1;
+$normal1->keywords = '关键词1';
+
+
+$normal2 = new stdclass();
+$normal2->title = '标题';
+$normal2->openedBuild = 1;
+$normal2->product = 1;
+$normal2->branch = 0;
+$normal2->module = 1;
+$normal2->project = 1;
+$normal2->execution = 11;
+$normal2->deadline = '2023-01-01';
+$normal2->steps = '步骤';
+$normal2->type = 'config';
+$normal2->pri = 1;
+$normal2->severity = 1;
+$normal2->keywords = '关键词';
+
+$bugs1 = array('emptyTitle' => $emptyTitle);
+$bugs2 = array('emptyBuild' => $emptyBuild);
+$bugs3 = array('emptyTitle' => $emptyTitle, 'emptyBuild' => $emptyBuild);
+$bugs4 = array('emptyItem' => $emptyItem);
+$bugs5 = array('emptyAll' => $emptyAll);
+$bugs6 = array('emptyItem' => $emptyItem, 'emptyAll' => $emptyAll);
+$bugs7 = array('hasTitleBuild' => $hasTitleBuild, 'narmal1' => $normal1, 'narmal2' => $normal2);
+
+$bug = new bugTest();
+
+r($bug->checkBugsForBatchCreateTest($bugs1)) && p() && e('『Bug标题』不能为空。'); // 测试检查 不输入标题 的bugs
+r($bug->checkBugsForBatchCreateTest($bugs2)) && p() && e('『影响版本』不能为空。'); // 测试检查 不输入版本 的bugs
+r($bug->checkBugsForBatchCreateTest($bugs3)) && p() && e('『Bug标题』不能为空。『影响版本』不能为空。'); // 测试检查 不输入标题 不输入版本 的bugs
+r($bug->checkBugsForBatchCreateTest($bugs4)) && p() && e('『Bug标题』不能为空。『影响版本』不能为空。'); // 测试检查 空对象 的bugs
+r($bug->checkBugsForBatchCreateTest($bugs5)) && p() && e('『Bug标题』不能为空。『影响版本』不能为空。'); // 测试检查 不输入任务字段 的bugs
+r($bug->checkBugsForBatchCreateTest($bugs6)) && p() && e('『Bug标题』不能为空。『影响版本』不能为空。『Bug标题』不能为空。『影响版本』不能为空。'); // 测试检查 空对象 不输入任务字段 的bugs
+r($bug->checkBugsForBatchCreateTest($bugs7)) && p() && e('hasTitleBuild,narmal1,narmal2'); // 测试检查 有标题和版本 两个有所有字段 的bugs
diff --git a/module/bug/test/model/processimageforbatchcreate.php b/module/bug/test/model/processimageforbatchcreate.php
new file mode 100755
index 0000000000..86edcffb7f
--- /dev/null
+++ b/module/bug/test/model/processimageforbatchcreate.php
@@ -0,0 +1,107 @@
+#!/usr/bin/env php
+gen(1);
+su('admin');
+
+/**
+
+title=bugModel->processImageForBatchCreate();
+cid=1
+pid=1
+
+*/
+
+$uploadImage = array();
+$uploadImage[] = '0';
+$uploadImage[] = '1';
+$uploadImage[] = '2';
+$uploadImage[] = '3';
+
+$jpgFile = array();
+$jpgFile['realpath'] = $tester->app->tmpRoot . '1.jpg';
+$jpgFile['pathname'] = '1.jpg';
+$jpgFile['title'] = '1';
+$jpgFile['extension'] = 'jpg';
+
+$jpegFile = array();
+$jpegFile['realpath'] = $tester->app->tmpRoot . '2.jpeg';
+$jpegFile['pathname'] = '2.jpeg';
+$jpegFile['title'] = '2';
+$jpegFile['extension'] = 'jpeg';
+
+$pngFile = array();
+$pngFile['realpath'] = $tester->app->tmpRoot . '3.png';
+$pngFile['pathname'] = '3.png';
+$pngFile['title'] = '3';
+$pngFile['extension'] = 'png';
+
+$gifFile = array();
+$gifFile['realpath'] = $tester->app->tmpRoot . '4.gif';
+$gifFile['pathname'] = '4.gif';
+$gifFile['title'] = '4';
+$gifFile['extension'] = 'gif';
+
+$textFile = array();
+$textFile['realpath'] = $tester->app->tmpRoot . 'text.txt';
+$textFile['pathname'] = 'text.txt';
+$textFile['title'] = 'text';
+$textFile['extension'] = 'txt';
+
+$bugImagesFiles = array('jpg' => $jpgFile, 'jpeg' => $jpegFile, 'png' => $pngFile, 'gif' => $gifFile, 'text' => $textFile);
+$uploadImageList = array('jpg', 'jpeg', 'png', 'gif', 'text');
+
+foreach($bugImagesFiles as $bugImagesFile)
+{
+ if(!empty($bugImagesFile['realpath']) and !is_file($bugImagesFile['realpath']))
+ {
+ $theFile = fopen($bugImagesFile['realpath'], 'w');
+ fclose($theFile);
+ }
+}
+
+$bug1 = new stdclass();
+$bug1->steps = '';
+
+$bug2 = new stdclass();
+$bug2->steps = '';
+
+$bug3 = new stdclass();
+$bug3->steps = '';
+
+$bug4 = new stdclass();
+$bug4->steps = '';
+
+$bug5 = new stdclass();
+$bug5->steps = '';
+
+$bug6 = new stdclass();
+$bug6->steps = '';
+
+$bug = new bugTest();
+
+r($bug->processImageForBatchCreateTest($bug1, $uploadImageList[0], $bugImagesFiles)) && p('pathname,title,extension,addedBy') && e('1.jpg,1,jpg,admin'); // 测试处理 jpg 类型的图片
+r($bug->processImageForBatchCreateTest($bug2, $uploadImageList[1], $bugImagesFiles)) && p('pathname,title,extension,addedBy') && e('2.jpeg,2,jpeg,admin'); // 测试处理 jpeg 类型的图片
+r($bug->processImageForBatchCreateTest($bug3, $uploadImageList[2], $bugImagesFiles)) && p('pathname,title,extension,addedBy') && e('3.png,3,png,admin'); // 测试处理 png 类型的图片
+r($bug->processImageForBatchCreateTest($bug4, $uploadImageList[3], $bugImagesFiles)) && p('pathname,title,extension,addedBy') && e('4.gif,4,gif,admin'); // 测试处理 gif 类型的图片
+r($bug->processImageForBatchCreateTest($bug6, $uploadImageList[4], $bugImagesFiles)) && p('pathname,title,extension,addedBy') && e('text.txt,text,txt,~~'); // 测试处理 文本类型
+
+$zfile = $tester->app->loadClass('zfile');
+
+foreach($bugImagesFiles as $bugImagesFile)
+{
+ if(!empty($bugImagesFile['realpath']) and is_file($bugImagesFile['realpath']))
+ {
+ $zfile->removeFile($bugImagesFile['realpath']);
+ }
+ if(!empty($bugImagesFile['pathname']) and is_file($bugImagesFile['pathname']))
+ {
+ $zfile->removeFile($bugImagesFile['pathname']);
+ }
+ if(!empty($bugImagesFile['title']) and is_file($bugImagesFile['title']))
+ {
+ $zfile->removeFile($bugImagesFile['title']);
+ }
+}
diff --git a/module/bug/test/model/yaml/afterbatchcreate/bug_afterbatchcreate.yaml b/module/bug/test/model/yaml/afterbatchcreate/bug_afterbatchcreate.yaml
new file mode 100644
index 0000000000..06f225401d
--- /dev/null
+++ b/module/bug/test/model/yaml/afterbatchcreate/bug_afterbatchcreate.yaml
@@ -0,0 +1,13 @@
+---
+title: zt_bug
+author: Mengyi Liu
+version: "1.0"
+fields:
+- field: assignedTo
+ range: user1
+- field: status
+ range: active
+- field: execution
+ range: 11
+...
+
diff --git a/module/bug/test/model/yaml/afterbatchcreate/kanbancell_afterbatchcreate.yaml b/module/bug/test/model/yaml/afterbatchcreate/kanbancell_afterbatchcreate.yaml
new file mode 100644
index 0000000000..ebc3450fef
--- /dev/null
+++ b/module/bug/test/model/yaml/afterbatchcreate/kanbancell_afterbatchcreate.yaml
@@ -0,0 +1,19 @@
+---
+title: zt_kanbancell
+author: Mengyi Liu
+version: "1.0"
+fields:
+- field: id
+ range: 1-100
+- field: kanban
+ range: 11
+- field: lane
+ range: 1
+- field: column
+ range: 1-9
+- field: type
+ range: "bug"
+- field: cards
+ range: "[]"
+...
+
diff --git a/module/bug/test/model/yaml/afterbatchcreate/kanbancolumn_afterbatchcreate.yaml b/module/bug/test/model/yaml/afterbatchcreate/kanbancolumn_afterbatchcreate.yaml
new file mode 100644
index 0000000000..fb84cb2f99
--- /dev/null
+++ b/module/bug/test/model/yaml/afterbatchcreate/kanbancolumn_afterbatchcreate.yaml
@@ -0,0 +1,19 @@
+---
+title: zt_kanbancolumn
+author: Mengyi Liu
+version: "1.0"
+fields:
+- field: id
+ range: 1-9
+- field: region
+ range: 1
+- field: type
+ range: unconfirmed,confirmed,resolving,fixing,fixed,test,testing,tested,closed
+- field: parent
+ range: "0{2},`-1`,2{2},0,5{2},0"
+- field: name
+ range: 待确认,已确认,解决中,进行中,完成,测试,测试中,测试完毕,已关闭
+- field: limit
+ range: "`-1`"
+...
+
diff --git a/module/bug/test/model/yaml/afterbatchcreate/kanbanlane_afterbatchcreate.yaml b/module/bug/test/model/yaml/afterbatchcreate/kanbanlane_afterbatchcreate.yaml
new file mode 100644
index 0000000000..4376a0e298
--- /dev/null
+++ b/module/bug/test/model/yaml/afterbatchcreate/kanbanlane_afterbatchcreate.yaml
@@ -0,0 +1,19 @@
+---
+title: zt_kanbanlane
+author: Mengyi Liu
+version: "1.0"
+fields:
+- field: id
+ range: 1-10
+- field: execution
+ range: 11
+- field: type
+ range: "bug"
+- field: region
+ range: 1
+- field: lastEditedTime
+ range: "20220101 000000"
+ type: timestamp
+ format: "YY/MM/DD hh:mm:ss"
+...
+
diff --git a/module/bug/test/model/yaml/afterbatchcreate/kanbanregion_afterbatchcreate.yaml b/module/bug/test/model/yaml/afterbatchcreate/kanbanregion_afterbatchcreate.yaml
new file mode 100644
index 0000000000..300db12fd6
--- /dev/null
+++ b/module/bug/test/model/yaml/afterbatchcreate/kanbanregion_afterbatchcreate.yaml
@@ -0,0 +1,17 @@
+---
+title: zt_kanbanregion
+author: Mengyi Liu
+version: "1.0"
+fields:
+- field: id
+ range: 1-10
+- field: space
+ range: 0
+- field: kanban
+ range: 11
+- field: lastEditedDate
+ range: "20220101 000000"
+ type: timestamp
+ format: "YY/MM/DD hh:mm:ss"
+...
+
diff --git a/module/bug/test/model/yaml/afterbatchcreate/project_afterbatchcreate.yaml b/module/bug/test/model/yaml/afterbatchcreate/project_afterbatchcreate.yaml
new file mode 100644
index 0000000000..e9d090d55a
--- /dev/null
+++ b/module/bug/test/model/yaml/afterbatchcreate/project_afterbatchcreate.yaml
@@ -0,0 +1,9 @@
+---
+title: zt_project
+author: Mengyi Liu
+version: "1.0"
+fields:
+- field: type
+ range: scrum
+...
+
diff --git a/module/bug/test/model/yaml/batchcreate/kanbancell_batchcreate.yaml b/module/bug/test/model/yaml/batchcreate/kanbancell_batchcreate.yaml
new file mode 100644
index 0000000000..ebc3450fef
--- /dev/null
+++ b/module/bug/test/model/yaml/batchcreate/kanbancell_batchcreate.yaml
@@ -0,0 +1,19 @@
+---
+title: zt_kanbancell
+author: Mengyi Liu
+version: "1.0"
+fields:
+- field: id
+ range: 1-100
+- field: kanban
+ range: 11
+- field: lane
+ range: 1
+- field: column
+ range: 1-9
+- field: type
+ range: "bug"
+- field: cards
+ range: "[]"
+...
+
diff --git a/module/bug/test/model/yaml/batchcreate/kanbancolumn_batchcreate.yaml b/module/bug/test/model/yaml/batchcreate/kanbancolumn_batchcreate.yaml
new file mode 100644
index 0000000000..fb84cb2f99
--- /dev/null
+++ b/module/bug/test/model/yaml/batchcreate/kanbancolumn_batchcreate.yaml
@@ -0,0 +1,19 @@
+---
+title: zt_kanbancolumn
+author: Mengyi Liu
+version: "1.0"
+fields:
+- field: id
+ range: 1-9
+- field: region
+ range: 1
+- field: type
+ range: unconfirmed,confirmed,resolving,fixing,fixed,test,testing,tested,closed
+- field: parent
+ range: "0{2},`-1`,2{2},0,5{2},0"
+- field: name
+ range: 待确认,已确认,解决中,进行中,完成,测试,测试中,测试完毕,已关闭
+- field: limit
+ range: "`-1`"
+...
+
diff --git a/module/bug/test/model/yaml/batchcreate/kanbanlane_batchcreate.yaml b/module/bug/test/model/yaml/batchcreate/kanbanlane_batchcreate.yaml
new file mode 100644
index 0000000000..4376a0e298
--- /dev/null
+++ b/module/bug/test/model/yaml/batchcreate/kanbanlane_batchcreate.yaml
@@ -0,0 +1,19 @@
+---
+title: zt_kanbanlane
+author: Mengyi Liu
+version: "1.0"
+fields:
+- field: id
+ range: 1-10
+- field: execution
+ range: 11
+- field: type
+ range: "bug"
+- field: region
+ range: 1
+- field: lastEditedTime
+ range: "20220101 000000"
+ type: timestamp
+ format: "YY/MM/DD hh:mm:ss"
+...
+
diff --git a/module/bug/test/model/yaml/batchcreate/kanbanregion_batchcreate.yaml b/module/bug/test/model/yaml/batchcreate/kanbanregion_batchcreate.yaml
new file mode 100644
index 0000000000..300db12fd6
--- /dev/null
+++ b/module/bug/test/model/yaml/batchcreate/kanbanregion_batchcreate.yaml
@@ -0,0 +1,17 @@
+---
+title: zt_kanbanregion
+author: Mengyi Liu
+version: "1.0"
+fields:
+- field: id
+ range: 1-10
+- field: space
+ range: 0
+- field: kanban
+ range: 11
+- field: lastEditedDate
+ range: "20220101 000000"
+ type: timestamp
+ format: "YY/MM/DD hh:mm:ss"
+...
+
diff --git a/module/bug/test/model/yaml/batchcreate/project_batchcreate.yaml b/module/bug/test/model/yaml/batchcreate/project_batchcreate.yaml
new file mode 100644
index 0000000000..e9d090d55a
--- /dev/null
+++ b/module/bug/test/model/yaml/batchcreate/project_batchcreate.yaml
@@ -0,0 +1,9 @@
+---
+title: zt_project
+author: Mengyi Liu
+version: "1.0"
+fields:
+- field: type
+ range: scrum
+...
+
diff --git a/module/bug/zen.php b/module/bug/zen.php
index 9981c671f7..f231410302 100644
--- a/module/bug/zen.php
+++ b/module/bug/zen.php
@@ -1780,31 +1780,6 @@ class bugZen extends bug
$bug->{$extendField->field} = htmlSpecialString($bug->{$extendField->field});
}
- /* When the bug is created by uploading an image, add the image to the step of the bug. */
- if(!empty($data->uploadImage[$index]))
- {
- $this->loadModel('file');
- $fileName = $data->uploadImage[$index];
- $file = $bugImagesFile[$fileName];
- $realPath = $file['realpath'];
-
- if(rename($realPath, $this->file->savePath . $this->file->getSaveName($file['pathname'])))
- {
- if(in_array($file['extension'], $this->config->file->imageExtensions))
- {
- $file['addedBy'] = $this->app->user->account;
- $file['addedDate'] = helper::now();
- $this->dao->insert(TABLE_FILE)->data($file, 'realpath')->exec();
-
- $fileID = $this->dao->lastInsertID();
- $bug->steps .= '
';
- }
- }
- else
- {
- unset($file);
- }
- }
return $bug;
}