Merge branch 'sprint/191_liumengyi_unittest' into 'master'

* Add unit test of sprint 191.

See merge request easycorp/zentaopms!3534
This commit is contained in:
孙广明
2022-05-20 01:37:49 +00:00
4 changed files with 204 additions and 77 deletions
+33
View File
@@ -2045,4 +2045,37 @@ class bugTest
return $array;
}
}
/**
* Test get bugs of assigned by me.
*
* @param string $productIDList
* @param string $moduleIDList
* @access public
* @return string
*/
public function getByAssignedbymeTest($productIDList, $moduleIDList)
{
global $tester;
$executions = $tester->loadModel('execution')->getPairs('0', 'all', 'empty|withdelete');
$bugs = $this->objectModel->getByAssignedbyme($productIDList, 'all', $moduleIDList, $executions, 'id_desc', null, 0);
$title = '';
foreach($bugs as $bug)
{
$title .= ',' . $bug->title;
}
$title = trim($title, ',');
$title = str_replace("'", '', $title);
if(dao::isError())
{
return dao::getError();
}
else
{
return $title;
}
}
}
+103 -77
View File
@@ -5,13 +5,13 @@ class storyTest
{
global $tester;
$this->objectModel = $tester->loadModel('story');
}
}
/**
* Test get by id.
*
* @param int $storyID
* @param int $version
*
* @param int $storyID
* @param int $version
* @access public
* @return void
*/
@@ -26,9 +26,9 @@ class storyTest
/**
* Test get by list.
*
* @param int $storyIdList
* @param string $type
*
* @param int $storyIdList
* @param string $type
* @access public
* @return void
*/
@@ -43,9 +43,9 @@ class storyTest
/**
* Test get test stories.
*
* @param array $storyIdList
* @param int $executionID
*
* @param array $storyIdList
* @param int $executionID
* @access public
* @return void
*/
@@ -60,8 +60,8 @@ class storyTest
/**
* Test get story specs.
*
* @param array $storyIdList
*
* @param array $storyIdList
* @access public
* @return void
*/
@@ -76,7 +76,7 @@ class storyTest
/**
* Test get affected scope.
*
*
* @param int $storyID
* @access public
* @return void
@@ -84,7 +84,7 @@ class storyTest
public function getAffectedScopeTest($storyID)
{
global $tester;
$story = $tester->loadModel('story')->getById($storyID);
$story = $tester->loadModel('story')->getById($storyID);
$scope = $this->objectModel->getAffectedScope($story);
if(dao::isError()) return dao::getError();
@@ -94,8 +94,8 @@ class storyTest
/**
* Test get requierements.
*
* @param int $productID
*
* @param int $productID
* @access public
* @return void
*/
@@ -110,11 +110,11 @@ class storyTest
/**
* Test create story.
*
* @param int $executionID
* @param int $bugID
* @param string $from
* @param string $extra
*
* @param int $executionID
* @param int $bugID
* @param string $from
* @param string $extra
* @access public
* @return void
*/
@@ -128,14 +128,14 @@ class storyTest
global $tester;
$storyID = $result['id'];
return $tester->loadModel('story')->getById($storyID);
return $tester->loadModel('story')->getById($storyID);
}
/**
* Test create story from gitlab issue.
*
* @param int $story
* @param int $executionID
*
* @param int $story
* @param int $executionID
* @access public
* @return void
*/
@@ -146,15 +146,15 @@ class storyTest
if(dao::isError()) return dao::getError();
global $tester;
return $tester->loadModel('story')->getById($storyID);
return $tester->loadModel('story')->getById($storyID);
}
/**
* Test batch create stories.
*
* @param int $productID
* @param int $branch
* @param string $type
*
* @param int $productID
* @param int $branch
* @param string $type
* @param array $params
* @access public
* @return void
@@ -176,8 +176,8 @@ class storyTest
/**
* Test change story.
*
* @param int $storyID
*
* @param int $storyID
* @param array $params
* @access public
* @return void
@@ -196,8 +196,8 @@ class storyTest
/**
* Test update story.
*
* @param int $storyID
*
* @param int $storyID
* @param array $params
* @access public
* @return void
@@ -215,10 +215,10 @@ class storyTest
/**
* Test update story order of plan.
*
* @param int $storyID
* @param string $planIDList
* @param string $oldPlanIDList
*
* @param int $storyID
* @param string $planIDList
* @param string $oldPlanIDList
* @access public
* @return void
*/
@@ -234,8 +234,8 @@ class storyTest
/**
* Test compute estimate.
*
* @param int $storyID
*
* @param int $storyID
* @access public
* @return void
*/
@@ -250,7 +250,7 @@ class storyTest
/**
* Test batch update stories.
*
*
* @access public
* @return void
*/
@@ -268,8 +268,8 @@ class storyTest
/**
* Test review story.
*
* @param int $storyID
*
* @param int $storyID
* @param array $params
* @access public
* @return void
@@ -287,10 +287,10 @@ class storyTest
/**
* Test batch review.
*
* @param int $storyIdList
* @param int $result
* @param int $reason
*
* @param int $storyIdList
* @param int $result
* @param int $reason
* @access public
* @return void
*/
@@ -306,9 +306,9 @@ class storyTest
/**
* Test story subdivide.
*
* @param int $storyID
* @param array $stories
*
* @param int $storyID
* @param array $stories
* @access public
* @return void
*/
@@ -331,8 +331,8 @@ class storyTest
/**
* Test close a story.
*
* @param int $storyID
*
* @param int $storyID
* @param array $params
* @access public
* @return void
@@ -350,8 +350,8 @@ class storyTest
/**
* Test batch close story.
*
* @param array $params
*
* @param array $params
* @access public
* @return void
*/
@@ -369,9 +369,9 @@ class storyTest
/**
* Test batch change story module.
*
* @param int $storyIdList
* @param int $moduleID
*
* @param int $storyIdList
* @param int $moduleID
* @access public
* @return void
*/
@@ -387,10 +387,10 @@ class storyTest
/**
* Test batch change story plan.
*
* @param arary $storyIdList
* @param int $planID
* @param int $oldPlanID
*
* @param arary $storyIdList
* @param int $planID
* @param int $oldPlanID
* @access public
* @return void
*/
@@ -406,11 +406,11 @@ class storyTest
/**
* Test batch change story branch.
*
* @param arary $storyIdList
* @param int $branchID
* @param string $confirm
* @param array $plans
*
* @param arary $storyIdList
* @param int $branchID
* @param string $confirm
* @param array $plans
* @access public
* @return void
*/
@@ -426,9 +426,9 @@ class storyTest
/**
* Test batch change stage.
*
* @param arrau $storyIdList
* @param string $stage
*
* @param arrau $storyIdList
* @param string $stage
* @access public
* @return void
*/
@@ -444,9 +444,9 @@ class storyTest
/**
* Test story batch to task.
*
* @param int $executionID
* @param int $projectID
*
* @param int $executionID
* @param int $projectID
* @param array $params
* @access public
* @return void
@@ -465,8 +465,8 @@ class storyTest
/**
* Test assign a story.
*
* @param int $storyID
*
* @param int $storyID
* @param string $assignedTo
* @access public
* @return void
@@ -484,8 +484,8 @@ class storyTest
/**
* Test batch assign story.
*
* @param array $params
*
* @param array $params
* @access public
* @return void
*/
@@ -500,4 +500,30 @@ class storyTest
$storyIdList = array_keys($changes);
return $this->objectModel->getByList($storyIdList);
}
/**
* Test get stories by assignedBy.
*
* @param int $productID
* @param int $branch
* @access public
* @return string
*/
public function getByAssignedByTest($productID, $branch)
{
global $tester;
$stories = $this->objectModel->getByAssignedBy($productID, $branch, $modules = array(), $account = $tester->app->user->account, $type = 'story', $orderBy = '', $pager = null);
$title = '';
foreach($stories as $story)
{
$title .= ',' . $story->title;
}
$title = trim($title, ',');
$title = str_replace("'", '', $title);
if(dao::isError()) return dao::getError();
return $title;
}
}
+38
View File
@@ -0,0 +1,38 @@
#!/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->getByAssignedbyme();
cid=1
pid=1
查询产品1 2 3 不存在的产品10001 与模块1821, 1825, 1831 不存在的模块1000001下由我指派的bug >> 0
查询产品1 2 3 不存在的产品10001 与模块1821, 1825下由我指派的bug >> 0
查询产品1 2 3 不存在的产品10001 与不存在的模块1000001下由我指派的bug >> 0
查询产品1 3与模块1821, 1825, 1831 不存在的模块1000001下由我指派的bug >> 0
查询产品1 3与模块1821, 1825下由我指派的bug >> 0
查询产品1 3与模块不存在的模块1000001下由我指派的bug >> 0
查询不存在的产品10001 与模块1821, 1825, 1831 不存在的模块1000001下由我指派的bug >> 0
查询不存在的产品10001 与模块1821, 1825下由我指派的bug >> 0
查询不存在的产品10001 与不存在的模块1000001下由我指派的bug >> 0
*/
$productIDList = array('1,2,3,1000001', '1,3', '1000001');
$moduleIDList = array('1821,1825,1831,1000001', '1821, 1825', '1000001');
$bug=new bugTest();
r($bug->getByAssignedbymeTest($productIDList[0], $moduleIDList[0])) && p('title') && e('0'); // 查询产品1 2 3 不存在的产品10001 与模块1821, 1825, 1831 不存在的模块1000001下由我指派的bug
r($bug->getByAssignedbymeTest($productIDList[0], $moduleIDList[1])) && p('title') && e('0'); // 查询产品1 2 3 不存在的产品10001 与模块1821, 1825下由我指派的bug
r($bug->getByAssignedbymeTest($productIDList[0], $moduleIDList[2])) && p('title') && e('0'); // 查询产品1 2 3 不存在的产品10001 与不存在的模块1000001下由我指派的bug
r($bug->getByAssignedbymeTest($productIDList[1], $moduleIDList[0])) && p('title') && e('0'); // 查询产品1 3与模块1821, 1825, 1831 不存在的模块1000001下由我指派的bug
r($bug->getByAssignedbymeTest($productIDList[1], $moduleIDList[1])) && p('title') && e('0'); // 查询产品1 3与模块1821, 1825下由我指派的bug
r($bug->getByAssignedbymeTest($productIDList[1], $moduleIDList[2])) && p('title') && e('0'); // 查询产品1 3与模块不存在的模块1000001下由我指派的bug
r($bug->getByAssignedbymeTest($productIDList[2], $moduleIDList[0])) && p('title') && e('0'); // 查询不存在的产品10001 与模块1821, 1825, 1831 不存在的模块1000001下由我指派的bug
r($bug->getByAssignedbymeTest($productIDList[2], $moduleIDList[1])) && p('title') && e('0'); // 查询不存在的产品10001 与模块1821, 1825下由我指派的bug
r($bug->getByAssignedbymeTest($productIDList[2], $moduleIDList[2])) && p('title') && e('0'); // 查询不存在的产品10001 与不存在的模块1000001下由我指派的bug
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/story.class.php';
su('admin');
/**
title=storyModel->getByAssignedbyme();
cid=1
pid=1
查看产品 1 由我指派的需求 >> 0
查看产品 2 由我指派的需求 >> 0
查看产品 3 由我指派的需求 >> 0
查看产品 4 由我指派的需求 >> 0
查看产品 5 由我指派的需求 >> 0
*/
$productIDList = array(1, 2, 3, 4 ,5);
$branch = 'all';
$story=new storyTest();
r($story->getByAssignedByTest($productIDList[0], $branch)) && p() && e('0'); // 查看产品 1 由我指派的需求
r($story->getByAssignedByTest($productIDList[1], $branch)) && p() && e('0'); // 查看产品 2 由我指派的需求
r($story->getByAssignedByTest($productIDList[2], $branch)) && p() && e('0'); // 查看产品 3 由我指派的需求
r($story->getByAssignedByTest($productIDList[3], $branch)) && p() && e('0'); // 查看产品 4 由我指派的需求
r($story->getByAssignedByTest($productIDList[4], $branch)) && p() && e('0'); // 查看产品 5 由我指派的需求