diff --git a/test/lib/init.php b/test/lib/init.php
index e14238f77b..112f4153e3 100644
--- a/test/lib/init.php
+++ b/test/lib/init.php
@@ -79,11 +79,11 @@ function p($keys = '', $delimiter = ',')
if(empty($_result)) return print(">> 0\n");
+ if(is_array($_result) and isset($_result['code']) and $_result['code'] == 'fail') return print(">> " . (string) $_result['message'] . "\n");
+
/* Print $_result. */
if(!$keys or !is_array($_result) and !is_object($_result)) return print(">> " . (string) $_result . "\n");
- if(is_array($_result) and isset($_result['code']) and $_result['code'] == 'fail') return print(">> " . (string) $_result['message'] . "\n");
-
$parts = explode(';', $keys);
$values = array();
foreach($parts as $part)
diff --git a/test/model/project/getByID.php b/test/model/project/getByID.php
index bdd9f180ee..880749453d 100755
--- a/test/model/project/getByID.php
+++ b/test/model/project/getByID.php
@@ -10,13 +10,95 @@ pid=1
*/
-$project = $tester->loadModel('project');
+class Tester
+{
+ public function __construct($user)
+ {
+ global $tester;
-r($project->getByID(11)) && p('code,type') && e('project1,project'); // 获取ID等于11的项目
+ su($user);
+ $this->project = $tester->loadModel('project');
+ }
-$result = empty($project->getByID(0)) ? 'No Data!' : '';
-r($result) && p() && e('No Data!'); // 获取ID等于0的项目
+ /**
+ * Get project by ID.
+ *
+ * @param int $projectID
+ * @access public
+ * @return object
+ */
+ public function getProjectByID($projectID)
+ {
+ return $this->project->getByID($projectID);
+ }
-r($project->getByID(1, 'program')) && p('name,type') && e('项目集1,program'); // 获取ID等于0的项目集
+ /**
+ * Get program by ID.
+ *
+ * @param int $programID
+ * @access public
+ * @return object
+ */
+ public function getProgramByID($programID)
+ {
+ return $this->project->getByID($programID, 'program');
+ }
-r($project->getByID(101, 'sprint')) && p('name,type') && e('迭代1,sprint'); // 获取ID等于101的迭代
+ /**
+ * Get sprint by ID.
+ *
+ * @param int $sprintID
+ * @access public
+ * @return object
+ */
+ public function getSprintByID($sprintID)
+ {
+ return $this->project->getByID($sprintID, 'sprint');
+ }
+
+ /**
+ * Get stage by ID.
+ *
+ * @param int $stageID
+ * @access public
+ * @return object
+ */
+ public function getStageByID($stageID)
+ {
+ return $this->project->getByID($stageID, 'stage');
+ }
+
+ /**
+ * Get Kanban by ID,
+ *
+ * @param int $kanbanID
+ * @access public
+ * @return void
+ */
+ public function getKanbanByID($kanbanID)
+ {
+ return $this->project->getByID($kanbanID, 'kanban');
+ }
+}
+
+$t = new Tester('admin');
+
+/* Get project by ID. */
+r($t->getProjectByID(11)) && p('code,type') && e('project1,project'); //获取ID等于11的项目
+r($t->getProjectByID(0)) && p('code,type') && e('0'); //获取不存在的项目
+
+/* Get program by ID. */
+r($t->getProgramByID(1)) && p('code,type') && e('program1,program'); //获取ID等于1的项目集
+r($t->getProgramByID(0)) && p('code,type') && e('0'); //获取不存在的项目集
+
+/* Get sprint by ID. */
+r($t->getSprintByID(101)) && p('code,type') && e('project1,sprint'); //获取ID等于101的冲刺
+r($t->getSprintByID(0)) && p('code,type') && e('0'); //获取不存在的冲刺
+
+/* Get stage by ID. */
+r($t->getStageByID(131)) && p('code,type') && e('project31,stage'); //获取ID等于131的阶段
+r($t->getStageByID(0)) && p('code,type') && e('0'); //获取不存在的阶段
+
+/* Get Kanban by ID. */
+r($t->getKanbanByID(161)) && p('code,type') && e('project61,kanban'); //获取ID等于161的阶段
+r($t->getKanbanByID(0)) && p('code,type') && e('0'); //获取不存在的看板
diff --git a/test/model/project/getByIdList.php b/test/model/project/getByIdList.php
new file mode 100755
index 0000000000..ac6b4a2608
--- /dev/null
+++ b/test/model/project/getByIdList.php
@@ -0,0 +1,61 @@
+#!/usr/bin/env php
+project = $tester->loadModel('project');
+ }
+
+ /**
+ * Get project by ID list.
+ *
+ * @param array $IDList
+ * @access public
+ * @return void
+ */
+ public function getProjects($IDList)
+ {
+ $projects = $this->project->getByIdList($IDList);
+ if(empty($projects))
+ {
+ $result = array();
+ $result['code'] = 'fail';
+ $result['message'] = 'No data.';
+
+ return $result;
+ }
+
+ foreach($projects as $project)
+ {
+ if(!in_array($project->id, $IDList))
+ {
+ $result = array();
+ $result['code'] = 'fail';
+ $result['message'] = 'Error data.';
+
+ return $result;
+ }
+ }
+
+ return count($projects);
+ }
+}
+
+$t = new Tester('admin');
+
+r($t->getProjects(array(0,11,12,13))) && p() && e('3'); // 查找ID为0、11、12、13的项目
+r($t->getProjects(array())) && p() && e('No data.'); // 查找空项目
diff --git a/test/model/project/getOverviewList.php b/test/model/project/getOverviewList.php
index 8ce1ae155e..45c6895b87 100755
--- a/test/model/project/getOverviewList.php
+++ b/test/model/project/getOverviewList.php
@@ -2,6 +2,14 @@
project = $tester->loadModel('project');
}
+ /**
+ * Get project by status.
+ *
+ * @param string $status
+ * @access public
+ * @return int
+ */
public function getBystatus($status)
{
$projects = $this->project->getOverviewList('byStatus', $status);
- if(!$projects) return 0;
+ if(!$projects)
+ {
+ $result = array();
+ $result['code'] = 'fail';
+ $result['message'] = 'No data.';
+
+ return $result;
+ }
+
+ if($status == 'undone') $status = 'wait,doing,suspended';
+
foreach($projects as $project)
{
- if($project->status != $status) return 0;
+ if(strpos(",$status,", $project->status) === false)
+ {
+ $result = array();
+ $result['code'] = 'fail';
+ $result['message'] = 'Error data.';
+
+ return $result;
+ }
}
+
return count($projects);
}
+ /**
+ * Get project list by order.
+ *
+ * @param string $orderBy
+ * @access public
+ * @return void
+ */
public function getListByOrder($orderBy)
{
$projects = $this->project->getOverviewList('byStatus', 'wait', $orderBy);
return checkOrder($projects, $orderBy);
}
+ /**
+ * Get project by ID.
+ *
+ * @param int $projectID
+ * @access public
+ * @return void
+ */
public function getByID($projectID)
{
return $this->project->getOverviewList('byID', $projectID);
@@ -38,12 +85,13 @@ class Tester
$t = new Tester('admin');
/* GetOverviewList('byStatus'). */
-r($t->getByStatus('wait')) && p('') && e('15'); // 获取未开始的项目
+r($t->getByStatus('wait')) && p() && e('15'); // 获取未开始的项目
+r($t->getByStatus('undone')) && p() && e('15'); // 获取状态不为done和closed的项目
/* GetOverviewList('byID', $id). */
r($t->getByID(11)) && p('11:id') && e('11'); // 根据项目ID获取项目详情
-r($t->getByID(10000)) && p('id') && e(''); // 获取不存在的项目
+r($t->getByID(10000)) && p('id') && e('0'); // 获取不存在的项目
/* GetOverviewList('byStatus', 'wait', $orderBy). */
-r($t->getListByOrder('id_asc')) && p() && e('true'); // 按照ID正序获取项目列表
-r($t->getListByOrder('name_desc')) && p() && e('true'); // 按照项目名称倒序获取项目列表
+r($t->getListByOrder('id_asc')) && p() && e('1'); //按照ID正序获取项目列表
+r($t->getListByOrder('name_desc')) && p() && e('1'); // 按照项目名称倒序获取项目列表
diff --git a/test/model/project/getPairsByIdList.php b/test/model/project/getPairsByIdList.php
new file mode 100755
index 0000000000..487e72035e
--- /dev/null
+++ b/test/model/project/getPairsByIdList.php
@@ -0,0 +1,61 @@
+#!/usr/bin/env php
+project = $tester->loadModel('project');
+ }
+
+ /**
+ * Get project pairs by ID list.
+ *
+ * @param array $IDList
+ * @access public
+ * @return int
+ */
+ public function getByIdList($IDList)
+ {
+ $projects = $this->project->getPairsByIdList($IDList);
+ if(empty($projects))
+ {
+ $result = array();
+ $result['code'] = 'fail';
+ $result['message'] = 'No data.';
+
+ return $result;
+ }
+
+ foreach($projects as $projectID => $projectName)
+ {
+ if(!empty($IDList) and !in_array($projectID, $IDList))
+ {
+ $result = array();
+ $result['code'] = 'fail';
+ $result['message'] = 'Error Data.';
+
+ return $result;
+ }
+ }
+
+ return count($projects);
+ }
+}
+
+$t = new Tester('admin');
+
+r($t->getByIdList(array(0,11,12,13))) && p() && e('3'); //查找ID为0、11、12、13的项目
+r($t->getByIdList(array())) && p() && e('90'); //查找所有项目
diff --git a/test/model/project/getPairsByProgram.php b/test/model/project/getPairsByProgram.php
new file mode 100755
index 0000000000..80b082ba99
--- /dev/null
+++ b/test/model/project/getPairsByProgram.php
@@ -0,0 +1,93 @@
+#!/usr/bin/env php
+project = $tester->loadModel('project');
+ }
+
+ /**
+ * Get project pairs by programID.
+ *
+ * @param int $programID
+ * @access public
+ * @return int
+ */
+ public function getByProgram($programID)
+ {
+ $projects = $this->project->getPairsByProgram($programID);
+ if(empty($projects))
+ {
+ $result = array();
+ $result['code'] = 'fail';
+ $result['message'] = 'No data.';
+
+ return $result;
+ }
+
+ return count($projects);
+ }
+
+ /**
+ * Get project pairs by status.
+ *
+ * @param string $status
+ * @access public
+ * @return int
+ */
+ public function getByStatus($status)
+ {
+ $projects = $this->project->getPairsByProgram(2, $status);
+ if(empty($projects))
+ {
+ $result = array();
+ $result['code'] = 'fail';
+ $result['message'] = 'No data.';
+
+ return $result;
+ }
+
+ return count($projects);
+ }
+
+ /**
+ * Get project list by order.
+ *
+ * @param string $orderBy
+ * @access public
+ * @return int
+ */
+ public function getListByOrder($orderBy)
+ {
+ $projects = $this->project->getPairsByProgram(3, 'doing', $orderBy);
+ return checkOrder($projects, $orderBy);
+ }
+}
+
+$t = new Tester('admin');
+
+/* Get project list by program ID. */
+r($t->getByProgram('')) && p() && e('90'); //查找管理员可查看的所有项目
+r($t->getByProgram(0)) && p() && e('No data.'); //查找独立项目
+r($t->getByProgram(1)) && p() && e('9'); //查找管理员可查看的所属项目集ID为1的项目
+
+/* Get project list by status. */
+r($t->getByStatus('wait')) && p() && e('3'); //查找管理员可查看的所属项目集ID为1且状态为wait的项目
+r($t->getByStatus('noclosed')) && p() && e('7'); //查找管理员可查看的所属项目集ID为1且状态不为closed的项目
+
+/* Get project list by order. */
+r($t->getListByOrder('id_desc')) && p() && e('1'); //按照ID降序排序查找项目
diff --git a/test/model/project/getProjectsConsumed.php b/test/model/project/getProjectsConsumed.php
new file mode 100755
index 0000000000..114702ce3b
--- /dev/null
+++ b/test/model/project/getProjectsConsumed.php
@@ -0,0 +1,13 @@
+#!/usr/bin/env php
+loadModel('project');
+
diff --git a/test/model/project/getStatData.php b/test/model/project/getStatData.php
new file mode 100755
index 0000000000..040edd1217
--- /dev/null
+++ b/test/model/project/getStatData.php
@@ -0,0 +1,12 @@
+#!/usr/bin/env php
+loadModel('project');
diff --git a/test/model/project/getSwitcher.php b/test/model/project/getSwitcher.php
index 7720dcae64..b454ac3b2d 100755
--- a/test/model/project/getSwitcher.php
+++ b/test/model/project/getSwitcher.php
@@ -12,7 +12,5 @@ pid=1
$project = $tester->loadModel('project');
-$result = empty($project->getSwitcher(11, 'project', 'browse')) ? 'Return!' : '';
-r($result) && p() && e('Return'); // 获取项目下拉菜单,项目列表页面没有项目下拉菜单
-
-r($project->getSwitcher(11, 'project', 'execution')) && p() && e("项目1"); // 获取项目ID为11的迭代列表页面的项目下拉菜单,查看是否包含项目ID为11的名称
+r($project->getSwitcher(11, 'project', 'browse')) && p() && e('0'); //获取项目下拉菜单,项目列表页面没有项目下拉菜单
+r($project->getSwitcher(11, 'project', 'execution')) && p() && e("项目1"); //获取项目ID为11的迭代列表页面的项目下拉菜单,查看是否包含项目ID为11的名称
diff --git a/test/model/project/getTotalBugByProject.php b/test/model/project/getTotalBugByProject.php
new file mode 100755
index 0000000000..0392338f08
--- /dev/null
+++ b/test/model/project/getTotalBugByProject.php
@@ -0,0 +1,11 @@
+#!/usr/bin/env php
+getByID(13);
$suspendProject = $projectModel->getByID(17);
$closedProject = $projectModel->getByID(18);
+/* Check wait project. */
r($projectModel->isClickable($waitProject, 'start')) && p() && e('1'); // 检查未开始项目的开始按钮
r($projectModel->isClickable($waitProject, 'finish')) && p() && e('1'); // 检查未开始项目的完成按钮
r($projectModel->isClickable($waitProject, 'close')) && p() && e('1'); // 检查未开始项目的关闭按钮
r($projectModel->isClickable($waitProject, 'suspend')) && p() && e('1'); // 检查未开始项目的暂停按钮
r($projectModel->isClickable($waitProject, 'activate')) && p() && e('0'); // 检查未开始项目的激活按钮
+/* Check doing project. */
r($projectModel->isClickable($doingProject, 'start')) && p() && e('0'); //检查进行中项目的开始按钮
r($projectModel->isClickable($doingProject, 'finish')) && p() && e('1'); //检查进行中项目的完成按钮
r($projectModel->isClickable($doingProject, 'close')) && p() && e('1'); //检查进行中项目的关闭按钮
r($projectModel->isClickable($doingProject, 'suspend')) && p() && e('1'); //检查进行中项目的暂停按钮
r($projectModel->isClickable($doingProject, 'activate')) && p() && e('0'); //检查进行中项目的激活按钮
+/* Check suspend project. */
r($projectModel->isClickable($suspendProject, 'start')) && p() && e('1'); //检查已暂停项目的开始按钮
r($projectModel->isClickable($suspendProject, 'finish')) && p() && e('0'); //检查已暂停项目的完成按钮
r($projectModel->isClickable($suspendProject, 'close')) && p() && e('1'); //检查已暂停项目的关闭按钮
r($projectModel->isClickable($suspendProject, 'suspend')) && p() && e('0'); //检查已暂停项目的暂停按钮
r($projectModel->isClickable($suspendProject, 'activate')) && p() && e('0'); //检查已暂停项目的激活按钮
+/* Check closed project. */
r($projectModel->isClickable($closedProject, 'start')) && p() && e('0'); //检查已关闭项目的开始按钮
r($projectModel->isClickable($closedProject, 'finish')) && p() && e('0'); //检查已关闭项目的完成按钮
r($projectModel->isClickable($closedProject, 'close')) && p() && e('0'); //检查已关闭项目的关闭按钮