* Sprint231 unit
This commit is contained in:
+199
-10
@@ -621,16 +621,16 @@ class executionTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get execution stat data.
|
* Get execution stat data.
|
||||||
*
|
*
|
||||||
* @param int $projectID
|
* @param int $projectID
|
||||||
* @param string $browseType
|
* @param string $browseType
|
||||||
* @param int $productID
|
* @param int $productID
|
||||||
* @param int $branch
|
* @param int $branch
|
||||||
* @param bool $withTasks
|
* @param bool $withTasks
|
||||||
* @param string $param
|
* @param string $param
|
||||||
* @param string $orderBy
|
* @param string $orderBy
|
||||||
* @param object $pager
|
* @param object $pager
|
||||||
* @access public
|
* @access public
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@@ -2287,4 +2287,193 @@ class executionTest
|
|||||||
return $returns;
|
return $returns;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Get bugs by search in execution.
|
||||||
|
*
|
||||||
|
* @param array $products
|
||||||
|
* @param int $executionID
|
||||||
|
* @param string $sql
|
||||||
|
* @param object $pager
|
||||||
|
* @param string $orderBy
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function getSearchBugsTest($products, $executionID, $sql, $pager = null, $orderBy = 'id_desc')
|
||||||
|
{
|
||||||
|
$object = $this->objectModel->getSearchBugs($products, $executionID, $sql, $pager, $orderBy);
|
||||||
|
|
||||||
|
if(dao::isError())
|
||||||
|
{
|
||||||
|
$error = dao::getError();
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Get kanban group data.
|
||||||
|
*
|
||||||
|
* @param array $stories
|
||||||
|
* @param array $tasks
|
||||||
|
* @param array $bugs
|
||||||
|
* @param string $type
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function getKanbanGroupDataTest($stories, $tasks, $bugs, $type = 'story')
|
||||||
|
{
|
||||||
|
$object = $this->objectModel->getKanbanGroupData($stories, $tasks, $bugs, $type);
|
||||||
|
|
||||||
|
if(dao::isError())
|
||||||
|
{
|
||||||
|
$error = dao::getError();
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(count((array)$object['closed']) == 0 and count((array)$object['nokey']) == 0) return 'empty';
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Get Prev Kanban.
|
||||||
|
*
|
||||||
|
* @param int $executionID
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function getPrevKanbanTest($executionID)
|
||||||
|
{
|
||||||
|
$result = $this->objectModel->getPrevKanban($executionID);
|
||||||
|
|
||||||
|
if(dao::isError())
|
||||||
|
{
|
||||||
|
$error = dao::getError();
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return !$result ? 'empty' : $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test save Kanban Data.
|
||||||
|
*
|
||||||
|
* @param int $executionID
|
||||||
|
* @param array $kanbanDatas
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function saveKanbanDataTest($executionID, $kanbanDatas = '')
|
||||||
|
{
|
||||||
|
if($kanbanDatas === '')
|
||||||
|
{
|
||||||
|
global $tester;
|
||||||
|
$contents = array('story', 'wait', 'doing', 'done', 'cancel');
|
||||||
|
$stories = $tester->loadModel('story')->getExecutionStories($executionID, 0, 0, 'id_asc');
|
||||||
|
$kanbanTasks = $this->objectModel->getKanbanTasks($executionID, "id");
|
||||||
|
$kanbanBugs = $tester->loadModel('bug')->getExecutionBugs($executionID);
|
||||||
|
$users = array();
|
||||||
|
$taskAndBugs = array();
|
||||||
|
foreach($kanbanTasks as $task)
|
||||||
|
{
|
||||||
|
$storyID = $task->storyID;
|
||||||
|
$status = $task->status;
|
||||||
|
$users[] = $task->assignedTo;
|
||||||
|
|
||||||
|
$taskAndBugs[$status]["task{$task->id}"] = $task;
|
||||||
|
}
|
||||||
|
foreach($kanbanBugs as $bug)
|
||||||
|
{
|
||||||
|
$storyID = $bug->story;
|
||||||
|
$status = $bug->status;
|
||||||
|
$status = $status == 'active' ? 'wait' : ($status == 'resolved' ? ($bug->resolution == 'postponed' ? 'cancel' : 'done') : $status);
|
||||||
|
$users[] = $bug->assignedTo;
|
||||||
|
|
||||||
|
$taskAndBugs[$status]["bug{$bug->id}"] = $bug;
|
||||||
|
}
|
||||||
|
|
||||||
|
$datas = array();
|
||||||
|
foreach($contents as $content)
|
||||||
|
{
|
||||||
|
if($content != 'story' and !isset($taskAndBugs[$content])) continue;
|
||||||
|
$datas[$content] = $content == 'story' ? $stories : $taskAndBugs[$content];
|
||||||
|
}
|
||||||
|
$kanbanDatas = $datas;
|
||||||
|
}
|
||||||
|
|
||||||
|
$object = $this->objectModel->saveKanbanData($executionID, $kanbanDatas);
|
||||||
|
|
||||||
|
if(dao::isError())
|
||||||
|
{
|
||||||
|
$error = dao::getError();
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$result = $this->objectModel->getPrevKanban($executionID);
|
||||||
|
return !$result ? 'empty' : $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Get lifetime by id list.
|
||||||
|
*
|
||||||
|
* @param array $idList
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function getLifetimeByIdListTest($idList = '')
|
||||||
|
{
|
||||||
|
$result = $this->objectModel->getLifetimeByIdList($idList);
|
||||||
|
|
||||||
|
if(dao::isError())
|
||||||
|
{
|
||||||
|
$error = dao::getError();
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!$result) return 'empty';
|
||||||
|
|
||||||
|
foreach($result as $id => $lifetime)
|
||||||
|
{
|
||||||
|
if(!$lifetime) $result[$id] = 'emptyLifetime';
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test Update user view of execution and it's product.
|
||||||
|
*
|
||||||
|
* @param int $executionID
|
||||||
|
* @param string $objectType
|
||||||
|
* @param array $users
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function updateUserViewTest($executionID, $objectType = 'sprint', $users = array())
|
||||||
|
{
|
||||||
|
$this->objectModel->updateUserView($executionID, $objectType, $users);
|
||||||
|
|
||||||
|
if(dao::isError())
|
||||||
|
{
|
||||||
|
$error = dao::getError();
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(count($users) > 0) su($users[0]);
|
||||||
|
|
||||||
|
global $tester;
|
||||||
|
return $tester->app->user->view->sprints;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||||
|
include dirname(dirname(dirname(__FILE__))) . '/class/execution.class.php';
|
||||||
|
su('admin');
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
title=测试executionModel->getKanbanGroupData();
|
||||||
|
cid=1
|
||||||
|
pid=1
|
||||||
|
|
||||||
|
空数据查询 >> empty
|
||||||
|
查询执行162需求 >> 软件需求246
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$execution = new executionTest();
|
||||||
|
|
||||||
|
$executionID = 162;
|
||||||
|
$stories = $tester->loadModel('story')->getExecutionStories($executionID);
|
||||||
|
$tasks = $execution->getKanbanTasksTest($executionID, false);
|
||||||
|
$bugs = $tester->loadModel('bug')->getExecutionBugs($executionID);
|
||||||
|
|
||||||
|
r($execution->getKanbanGroupDataTest(array(), array(), array(), 'story')) && p('') && e('empty'); //空数据查询
|
||||||
|
r($execution->getKanbanGroupDataTest($stories, $tasks, $bugs, 'story')) && p('246:title') && e('软件需求246'); // 查询执行162需求
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||||
|
include dirname(dirname(dirname(__FILE__))) . '/class/execution.class.php';
|
||||||
|
su('admin');
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
title=测试executionModel->getLifetimeByIdList();
|
||||||
|
cid=1
|
||||||
|
pid=1
|
||||||
|
|
||||||
|
查询执行103和161 lifetime >> emptyLifetime
|
||||||
|
查询空执行 lifetime >> empty
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$executionIDList = array('103', '161');
|
||||||
|
|
||||||
|
$execution = new executionTest();
|
||||||
|
r($execution->getLifetimeByIdListTest($executionIDList)) && p('103') && e('emptyLifetime'); // 查询执行103和161 lifetime
|
||||||
|
r($execution->getLifetimeByIdListTest(array('0'))) && p('') && e('empty'); // 查询空执行 lifetime
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||||
|
include dirname(dirname(dirname(__FILE__))) . '/class/execution.class.php';
|
||||||
|
su('admin');
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
title=测试executionModel->getPrevKanban();
|
||||||
|
cid=1
|
||||||
|
pid=1
|
||||||
|
|
||||||
|
查询执行162数据 >> empty
|
||||||
|
保存数据后查询执行162数据 >> 246
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$execution = new executionTest();
|
||||||
|
|
||||||
|
$emptyExecutionID = 163;
|
||||||
|
$executionID = 162;
|
||||||
|
|
||||||
|
r($execution->getPrevKanbanTest($emptyExecutionID)) && p('') && e('empty'); //查询执行162数据
|
||||||
|
$execution->saveKanbanDataTest($executionID);
|
||||||
|
r($execution->getPrevKanbanTest($executionID)) && p('story:0') && e('246'); //保存数据后查询执行162数据
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||||
|
include dirname(dirname(dirname(__FILE__))) . '/class/execution.class.php';
|
||||||
|
su('admin');
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
title=测试executionModel->getSearchBugs();
|
||||||
|
cid=1
|
||||||
|
pid=1
|
||||||
|
|
||||||
|
查询产品1bug >> 测试单转Bug1
|
||||||
|
查询项目13bug优先级 >> 3
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$productIDList = array(1 => '正常产品1');
|
||||||
|
$executionIDList = array('103');
|
||||||
|
$sql = '1=1';
|
||||||
|
|
||||||
|
$execution = new executionTest();
|
||||||
|
r($execution->getSearchBugsTest($productIDList, 0, $sql)) && p('301:title') && e('测试单转Bug1'); // 查询产品1bug
|
||||||
|
r($execution->getSearchBugsTest(array(), $executionIDList[0], $sql)) && p('303:pri') && e(3); // 查询项目13bug优先级
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||||
|
include dirname(dirname(dirname(__FILE__))) . '/class/execution.class.php';
|
||||||
|
su('admin');
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
title=测试executionModel->saveKanbanData();
|
||||||
|
cid=1
|
||||||
|
pid=1
|
||||||
|
|
||||||
|
保存执行162看板数据 >> 246
|
||||||
|
保存执行162看板空数据 >> empty
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$execution = new executionTest();
|
||||||
|
|
||||||
|
$executionID = 162;
|
||||||
|
$emptyData = array();
|
||||||
|
|
||||||
|
r($execution->saveKanbanDataTest($executionID)) && p('story:0') && e('246'); //保存执行162看板数据
|
||||||
|
r($execution->saveKanbanDataTest($executionID, $emptyData)) && p('') && e('empty'); //保存执行162看板空数据
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||||
|
include dirname(dirname(dirname(__FILE__))) . '/class/execution.class.php';
|
||||||
|
$db->switchDB();
|
||||||
|
su('admin');
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
title=测试executionModel->updateUserView();
|
||||||
|
cid=1
|
||||||
|
pid=1
|
||||||
|
|
||||||
|
默认情况下的用户是否有201权限 >> 400
|
||||||
|
删除执行201后dev1用户是否有201权限 >> 0
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
$executionID = 201;
|
||||||
|
|
||||||
|
$execution = new executionTest();
|
||||||
|
r(strpos($execution->updateUserViewTest($executionID), '201,')) && p() && e('400'); // 默认情况下的用户是否有201权限
|
||||||
|
$tester->dao->update(TABLE_EXECUTION)->set('deleted')->eq(1)->where('id')->eq($executionID)->exec();
|
||||||
|
r(strpos($execution->updateUserViewTest($executionID, 'sprint', array('dev1')), '201,')) && p() && e('0'); // 删除执行201后dev1用户是否有201权限
|
||||||
|
$db->restoreDB();
|
||||||
Reference in New Issue
Block a user