Merge branch 'sgm_storytest' into 'master'

* Add story test and fix bug.

See merge request easycorp/zentaopms!2439
This commit is contained in:
朱金勇
2022-03-22 06:09:37 +00:00
14 changed files with 238 additions and 67 deletions

View File

@@ -247,6 +247,7 @@ class storyModel extends model
->checkIF($story->notifyEmail, 'notifyEmail', 'email')
->batchCheck($requiredFields, 'notempty')
->exec();
if(!dao::isError())
{
$storyID = $this->dao->lastInsertID();

View File

@@ -114,6 +114,8 @@ class weeklyModel extends model
*/
public function save($project, $date)
{
$this->dao->delete()->from(TABLE_WEEKLYREPORT)->where('project')->eq($project)->exec();
$report = new stdclass;
$report->pv = $this->getPV($project, $date);
$report->ev = $this->getEV($project, $date);

View File

@@ -58,6 +58,13 @@ class storyTest
return $objects;
}
/**
* Test get story specs.
*
* @param array $storyIdList
* @access public
* @return void
*/
public function getStorySpecsTest($storyIdList)
{
$objects = $this->objectModel->getStorySpecs($storyIdList);
@@ -67,85 +74,144 @@ class storyTest
return $objects;
}
public function getAffectedScopeTest($story)
/**
* Test get affected scope.
*
* @param int $storyID
* @access public
* @return void
*/
public function getAffectedScopeTest($storyID)
{
$objects = $this->objectModel->getAffectedScope($story);
global $tester;
$story = $tester->loadModel('story')->getById($storyID);
$scope = $this->objectModel->getAffectedScope($story);
if(dao::isError()) return dao::getError();
return $objects;
return $scope;
}
/**
* Test get requierements.
*
* @param int $productID
* @access public
* @return void
*/
public function getRequierementsTest($productID)
{
$objects = $this->objectModel->getRequierements($productID);
$requirements = $this->objectModel->getRequierements($productID);
if(dao::isError()) return dao::getError();
return $objects;
return $requirements;
}
public function createTest($executionID = 0, $bugID = 0, $from = '', $extra = '')
/**
* Test create story.
*
* @param int $executionID
* @param int $bugID
* @param string $from
* @param string $extra
* @access public
* @return void
*/
public function createTest($executionID = 0, $bugID = 0, $from = '', $extra = '', $params)
{
$objects = $this->objectModel->create($executionID = 0, $bugID = 0, $from = '', $extra = '');
$_POST = $params;
$result = $this->objectModel->create($executionID, $bugID, $from, $extra);
unset($_POST);
if(dao::isError()) return dao::getError();
return $objects;
global $tester;
$storyID = $result['id'];
return $tester->loadModel('story')->getById($storyID);
}
/**
* Test create story from gitlab issue.
*
* @param int $story
* @param int $executionID
* @access public
* @return void
*/
public function createStoryFromGitlabIssueTest($story, $executionID)
{
$objects = $this->objectModel->createStoryFromGitlabIssue($story, $executionID);
$storyID = $this->objectModel->createStoryFromGitlabIssue($story, $executionID);
if(dao::isError()) return dao::getError();
return $objects;
global $tester;
return $tester->loadModel('story')->getById($storyID);
}
public function batchCreateTest($productID = 0, $branch = 0, $type = 'story')
/**
* Test batch create stories.
*
* @param int $productID
* @param int $branch
* @param string $type
* @param array $params
* @access public
* @return void
*/
public function batchCreateTest($productID = 0, $branch = 0, $type = 'story', $params)
{
$objects = $this->objectModel->batchCreate($productID = 0, $branch = 0, $type = 'story');
$_POST = $params;
$results = $this->objectModel->batchCreate($productID, $branch, $type);
unset($_POST);
if(dao::isError()) return dao::getError();
return $objects;
foreach($results as $result) $storyIdList[] = $result->storyID;
global $tester;
$stories = $tester->loadModel('story')->getByList($storyIdList);
return $stories;
}
public function changeTest($storyID)
/**
* Test change story.
*
* @param int $storyID
* @param array $params
* @access public
* @return void
*/
public function changeTest($storyID, $params)
{
$objects = $this->objectModel->change($storyID);
$_POST = $params;
$this->objectModel->change($storyID);
unset($_POST);
if(dao::isError()) return dao::getError();
return $objects;
global $tester;
return $tester->loadModel('story')->getById($storyID);
}
public function updateTest($storyID)
/**
* Test update story.
*
* @param int $storyID
* @param array $params
* @access public
* @return void
*/
public function updateTest($storyID, $params)
{
$objects = $this->objectModel->update($storyID);
$_POST = $params;
$this->objectModel->update($storyID);
unset($_POST);
if(dao::isError()) return dao::getError();
return $objects;
}
public function updateStoryProductTest($storyID, $productID)
{
$objects = $this->objectModel->updateStoryProduct($storyID, $productID);
if(dao::isError()) return dao::getError();
return $objects;
}
public function updateParentStatusTest($storyID, $parentID = 0, $createAction = true)
{
$objects = $this->objectModel->updateParentStatus($storyID, $parentID = 0, $createAction = true);
if(dao::isError()) return dao::getError();
return $objects;
global $tester;
return $tester->loadModel('story')->getById($storyID);
}
public function updateStoryVersionTest($story)

View File

@@ -12,5 +12,20 @@ pid=1
*/
$story = new storyTest();
$stories = array();
$stories['title'] = array(1 => '测试需求1', 2 => '测试需求2', 3 => '');
$stories['pri'] = array(1 => 1, 2 => 2, 3 => 3);
$stories['spec'] = array(1 => '测试需求描述1', 2 => '测试需求描述2', 3 => '测试需求描述3');
$stories['verify'] = array(1 => '测试需求验收标准1', 2 => '测试需求验收标准2', 3 => '测试需求验收标准3');
$stories['estimate'] = array(1 => 1, 2 => 2, 3 => 3);
$stories['module'] = array(1 => 2221, 2 => 2222, 3 => 2223);
$stories['plan'] = array(1 => 1, 2 => 2, 3 => 3);
r() && p() && e();
$result1 = $story->batchCreateTest(1, 0, 'story', $stories);
$result2 = $story->batchCreateTest(2, 0, 'requirement', $stories);
r(count($result1)) && p() && e('2'); // 插入两条软件需求,判断返回的需求总量
r(count($result2)) && p() && e('2'); // 插入两条用户需求,判断返回的需求总量
r($result1) && p('401:title,type,pri,spec,estimate,stage,module') && e('测试需求1,story,1,测试需求描述1,1,planned,2221'); // 插入两条软件需求判断返回的title、type等信息
r($result2) && p('404:title,type,pri,spec,estimate,stage,module') && e('测试需求2,requirement,2,测试需求描述2,2,planned,2222'); // 插入两条用户需求判断返回的title、type等信息
system("./ztest init");

View File

@@ -11,6 +11,24 @@ pid=1
*/
$story = new storyTest();
$story = new storyTest();
$story1['title'] = '测试需求1变更标题';
$story1['spec'] = '测试需求1的变更描述';
$story1['verify'] = '测试需求1的变更验收标准';
$story1['estimate'] = 1;
r() && p() && e();
$story2 = $story1;
$story2['reviewer'] = array('admin', 'test2');
$story2['title'] = '';
$story3 = $story1;
$story3['reviewer'] = array('admin', 'test2');
$result1 = $story->changeTest(1, $story1);
$result2 = $story->changeTest(2, $story2);
$result3 = $story->changeTest(3, $story3);
r($result1[0]) && p() && e('『由谁评审』不能为空。'); // 不勾选【不需要评审】,不传入由谁评审时的变更,给出提示
r($result2) && p('title:0') && e('『研发需求名称』不能为空。'); // 变更时不填写需求名称,给出提示
r($result3) && p('status,title,spec,verify,estimate,lastEditedBy') && e('changed,测试需求1变更标题,测试需求1的变更描述,测试需求1的变更验收标准,1,admin'); // 正常变更需求判断返回的status、title等信息
system("./ztest init");

View File

@@ -11,6 +11,35 @@ pid=1
*/
$story = new storyTest();
$story = new storyTest();
$story1['title'] = '测试需求1';
$story1['pri'] = '3';
$story1['product'] = 1;
$story1['spec'] = '测试需求的描述111';
$story1['verify'] = '测试需求的验收标准111';
$story1['estimate'] = 3;
$story1['mailto'] = array('user2', 'test2', 'admin');
r() && p() && e();
$story2 = $story1;
$story2['reviewer'] = array('admin');
$story2['title'] = '测试需求2';
$story3 = $story1;
$story3['needNotReview'] = true;
$story3['product'] = 2;
$story3['title'] = '测试需求3';
$story4 = $story1;
$story4['needNotReview'] = true;
$story4['title'] = '';
$result1 = $story->createTest(11, 0, '', '', $story1);
$result2 = $story->createTest(11, 0, '', '', $story2);
$result3 = $story->createTest(0, 2, '', '', $story3);
$result4 = $story->createTest(12, 2, '', '', $story4);
r($result1[0]) && p() && e('『由谁评审』不能为空。'); //不勾选由谁评审并且不传入评审人的情况,报错
r($result2) && p('fromBug,stage,product') && e('0,projected,1'); //不勾选由谁评审传入评审人的情况,正常插入
r($result3) && p('title,fromBug,stage') && e('测试需求3,2,wait'); //勾选由谁评审不传入executionID的情况阶段为wait
r($result4) && p('title:0') && e('『研发需求名称』不能为空。'); //勾选由谁评审传入executionID和fromBug的情况阶段为projected
system("./ztest init");

View File

@@ -12,5 +12,26 @@ pid=1
*/
$story = new storyTest();
$story1->title = '测试需求1';
$story1->pri = '3';
$story1->product = 1;
$story1->spec = '测试需求的描述111';
$story1->verify = '测试需求的验收标准111';
$story1->estimate = 3;
$story1->mailto = array('user2', 'test2', 'admin');
r() && p() && e();
$story2 = clone $story1;
$story2->title = '';
$story3 = clone $story1;
$story3->product = 2;
$story3->title = '测试需求3';
$result1 = $story->createStoryFromGitlabIssueTest($story1, 11);
$result2 = $story->createStoryFromGitlabIssueTest($story2, 12);
$result3 = $story->createStoryFromGitlabIssueTest($story3, 0);
r($result1) && p('id,title,stage,product') && e('401,测试需求1,projected,1'); //创建正常的需求获取创建后的id、title、stage、product
r($result2) && p('title:0') && e('『研发需求名称』不能为空。'); //需求名称为空,给出提示
r($result3) && p('id,title,stage,product') && e('402,测试需求3,projected,2'); //创建正常的需求获取创建后的id、title、stage、product
system("./ztest init");

View File

@@ -12,5 +12,12 @@ pid=1
*/
$story = new storyTest();
$affectedScope1 = $story->getAffectedScopeTest(1);
$affectedScope2 = $story->getAffectedScopeTest(15);
$affectedScope3 = $story->getAffectedScopeTest(100);
r() && p() && e();
r(count($affectedScope1->tasks)) && p() && e('6'); //获取需求1影响任务的数量
r(count($affectedScope2->tasks)) && p() && e('0'); //获取需求15影响任务的数量
r($affectedScope1) && p('title') && e('用户需求版本三41'); //查看返回的需求1的title
r($affectedScope2) && p('title') && e('软件需求版本三55'); //查看返回的需求15的title
r($affectedScope3->executions) && p('125:name') && e('迭代25'); //查看需求100的影响的迭代的名字

View File

@@ -12,5 +12,12 @@ pid=1
*/
$story = new storyTest();
$requirements1 = $story->getRequierementsTest(1);
$requirements2 = $story->getRequierementsTest(5);
$requirements3 = $story->getRequierementsTest(null);
r() && p() && e();
r($requirements1) && p('1') && e('用户需求1'); //获取产品1下的第一个用户需求名称
r(count($requirements1)) && p() && e('2'); //获取产品1下的所有用户需求数量
r($requirements2) && p('17') && e('用户需求17'); //获取产品5下的第一个用户需求名称
r(count($requirements2)) && p() && e('2'); //获取产品5下的所有用户需求数量
r(count($requirements3)) && p() && e('0'); //获取产品ID为Null的用户需求数量

View File

@@ -12,5 +12,8 @@ pid=1
*/
$story = new storyTest();
$storyIdList = array(1, 15, 100);
r() && p() && e();
r($story->getStorySpecsTest($storyIdList)) && p('1:spec') && e('这是一个软件需求描述41'); //根据传入的需求ID列表获取最新版本的需求描述信息
r($story->getStorySpecsTest($storyIdList)) && p('15:verify') && e('这是一个需求验收55'); //根据传入的需求ID列表获取最新版本的验收标准信息
r(count($story->getStorySpecsTest($storyIdList))) && p() && e('2'); //传入三个需求ID判断获取到的需求描述信息数量

View File

@@ -15,5 +15,6 @@ $story = new storyTest();
$storyIdList1 = array(9, 41, 73);
$storyIdList2 = array(1, 2, 3);
r($story->getTestStoriesTest($storyIdList1, 103)) && p('9') && e('9');
r($story->getTestStoriesTest($storyIdList, 103)) && p() && e('0');
r($story->getTestStoriesTest($storyIdList1, 103)) && p('9') && e('9'); //获取和执行103关联的ID为9的测试类型的需求
r($story->getTestStoriesTest($storyIdList1, 111)) && p('41') && e('41'); //获取和执行111关联的ID为41的测试类型的需求
r($story->getTestStoriesTest($storyIdList2, 103)) && p() && e('0'); //获取和执行103关联的测试类型的需求,为空

View File

@@ -11,6 +11,16 @@ pid=1
*/
$story = new storyTest();
$story = new storyTest();
$story1['parent'] = 2;
$story1['pri'] = 4;
$story1['estimate'] = 1;
$story1['sourceNote'] = '测试来源备注1';
$story1['product'] = 2;
r() && p() && e();
$result1 = $story->updateTest(1, $story1);
$result2 = $story->updateTest(3, $story1);
r($result1) && p('parent,pri,estimate,sourceNote,product') && e('2,4,1,测试来源备注1,2'); // 编辑用户需求判断返回的信息stage为空
r($result2) && p('parent,pri,estimate,sourceNote,product') && e('2,4,1,测试来源备注1,2'); // 编辑软件需求判断返回的信息stage为waitparent为2
system("./ztest init");

View File

@@ -1,16 +0,0 @@
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/story.class.php';
su('admin');
/**
title=测试 storyModel->updateParentStatus();
cid=1
pid=1
*/
$story = new storyTest();
r() && p() && e();

View File

@@ -12,5 +12,12 @@ pid=1
*/
$story = new storyTest();
global $tester;
r() && p() && e();
$oldStory = $tester->loadModel('story')->getByID(1);
$tester->story->updateStoryProduct(1, 2);
$newStory = $tester->story->getByID(1);
r($oldStory) && p('product') && e('1'); // 判断需求变更所属产品之前的产品ID
r($newStory) && p('product') && e('2'); // 判断需求变更所属产品之后的产品ID
system("./ztest init");