* Add auto test of todo.
This commit is contained in:
Executable
+362
@@ -0,0 +1,362 @@
|
||||
<?php
|
||||
class todoTest
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $tester;
|
||||
$this->objectModel = $tester->loadModel('todo');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test create a todo.
|
||||
*
|
||||
* @param string $account
|
||||
* @param array $param
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function createTest($account, $param = array())
|
||||
{
|
||||
$config = array('day' => '', 'specify' => array('month' => 0, 'day' => 1), 'type' => 'day', 'beforeDays' => 0, 'end' => '');
|
||||
if(isset($param->date)) $param->date = $param->date == 'today' ? date('Y-m-d',time()) : date('Y-m-d',strtotime('+3 days'));
|
||||
|
||||
$createFields['config'] = $config;
|
||||
$createFields['type'] = 'custom';
|
||||
$createFields['name'] = '';
|
||||
$createFields['pri'] = 3;
|
||||
$createFields['desc'] = '';
|
||||
$createFields['status'] = 'wait';
|
||||
$createFields['begin'] = '0830';
|
||||
$createFields['end'] = '0900';
|
||||
|
||||
foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue;
|
||||
|
||||
foreach($param as $key => $value) $_POST[$key] = $value;
|
||||
|
||||
$objectID = $this->objectModel->create(date('Y').date('m'), $account);
|
||||
|
||||
unset($_POST);
|
||||
|
||||
if(dao::isError()) return array_values(dao::getError())[0][0];
|
||||
|
||||
$object = $objectID ? $this->objectModel->getByID($objectID) : 0;
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test batch create todos.
|
||||
*
|
||||
* @param array $param
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function batchCreateTest($param = array())
|
||||
{
|
||||
$createFields['date'] = date('Y-m-d',time());
|
||||
|
||||
foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue;
|
||||
|
||||
foreach($param as $key => $value) $_POST[$key] = $value;
|
||||
|
||||
$objects = $this->objectModel->batchCreate();
|
||||
|
||||
$todos = $this->objectModel->getByList($objects);
|
||||
|
||||
unset($_POST);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $todos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update a todo.
|
||||
*
|
||||
* @param int $todoID
|
||||
* @param array $param
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function updateTest($todoID, $param)
|
||||
{
|
||||
global $tester;
|
||||
$object = $tester->dbh->query("SELECT * FROM " . TABLE_TODO ." WHERE id = $todoID")->fetch();
|
||||
|
||||
foreach($object as $field => $value)
|
||||
{
|
||||
if(in_array($field, array_keys($param)))
|
||||
{
|
||||
$_POST[$field] = $param[$field];
|
||||
}
|
||||
else
|
||||
{
|
||||
$_POST[$field] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$change = $this->objectModel->update($todoID);
|
||||
if($change == array()) $change = '没有数据更新';
|
||||
|
||||
unset($_POST);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $change;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test batch update todos.
|
||||
*
|
||||
* @param array $param
|
||||
* @param int $todoID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function batchUpdateTest($param, $todoID)
|
||||
{
|
||||
$todoIDList = array('1' => '1', '2' => '2', '3' => '3');
|
||||
$dates = array('1' => date('Y-m-d',strtotime('+1 month')), '2' => date('Y-m-d',strtotime('-1 month +1 day')), '3' => date('Y-m-d',strtotime('-1 month +2 day')));
|
||||
$types = array('1' => 'custom', '2' => 'bug', '3' => 'task');
|
||||
$pris = array('1' => '1', '2' => '2', '3' => '3');
|
||||
$names = array('1' => '自定义1的待办', '2' => 'BUG2的待办', '3' => '任务3的待办');
|
||||
$descs = array('1' => '这是一个待办的描述1', '2' => '这是一个待办的描述2', '3' => '这是一个待办的描述3');
|
||||
$begins = array('1' => '1000', '2' => '1002', '3' => '1004');
|
||||
$ends = array('1' => '1400', '2' => '1402', '3' => '1404');
|
||||
$status = array('1' => 'wait', '2' => 'doing', '3' => 'done');
|
||||
|
||||
$batchUpdateFields['todoIDList'] = $todoIDList;
|
||||
$batchUpdateFields['dates'] = $dates;
|
||||
$batchUpdateFields['types'] = $types;
|
||||
$batchUpdateFields['pris'] = $pris;
|
||||
$batchUpdateFields['names'] = $names;
|
||||
$batchUpdateFields['descs'] = $descs;
|
||||
$batchUpdateFields['begins'] = $begins;
|
||||
$batchUpdateFields['ends'] = $ends;
|
||||
$batchUpdateFields['status'] = $status;
|
||||
|
||||
foreach($batchUpdateFields as $field => $value) $_POST[$field] = $value;
|
||||
|
||||
foreach($param as $key => $value) $_POST[$key] = $value;
|
||||
|
||||
$changes = $this->objectModel->batchUpdate();
|
||||
|
||||
unset($_POST);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $changes[$todoID];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test start a todo.
|
||||
*
|
||||
* @param int $todoID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function startTest($todoID)
|
||||
{
|
||||
$this->objectModel->start($todoID);
|
||||
$object = $this->objectModel->getByID($todoID);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test finish a todo.
|
||||
*
|
||||
* @param int $todoID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function finishTest($todoID)
|
||||
{
|
||||
$this->objectModel->finish($todoID);
|
||||
$object = $this->objectModel->getByID($todoID);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get info of a todo.
|
||||
*
|
||||
* @param int $todoID
|
||||
* @param bool $setImgSize
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getByIdTest($todoID, $setImgSize = false)
|
||||
{
|
||||
$object = $this->objectModel->getById($todoID);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get todo list of a user.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $account
|
||||
* @param string $status
|
||||
* @param int $limit
|
||||
* @param mixed $pager
|
||||
* @param string $orderBy
|
||||
* @param status $status
|
||||
* @param begin" $begin"
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getListTest($type = 'today', $account = '', $status = 'all', $limit = 0, $pager = null, $orderBy = "date, status, begin")
|
||||
{
|
||||
$objects = $this->objectModel->getList($type, $account, $status, $limit, $pager, $orderBy);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return count($objects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get todo by id list.
|
||||
*
|
||||
* @parami array $todoIDList
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getByListTest($todoIDList = 0)
|
||||
{
|
||||
$objects = $this->objectModel->getByList($todoIDList);
|
||||
|
||||
$name = '';
|
||||
foreach($objects as $todo) $name .= ',' . $todo->name;
|
||||
$name = trim($name, ',');
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* isClickableTest
|
||||
*
|
||||
* @param object $todo
|
||||
* @param string $action
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function isClickableTest($todo, $action)
|
||||
{
|
||||
$object = $this->objectModel->isClickable($todo, $action);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $object ? 1 : 2;
|
||||
}
|
||||
|
||||
public function createByCycleTest($todo)
|
||||
{
|
||||
$todo->cycle = '1';
|
||||
$todo->type = 'cycle';
|
||||
$todo->pri = 3;
|
||||
$todo->desc = '';
|
||||
$todo->status = 'wait';
|
||||
$todo->begin = '0830';
|
||||
$todo->end = '0900';
|
||||
$todo->account = 'admin';
|
||||
$todo->idvalue = '0';
|
||||
$todo->vision = 'rnd';
|
||||
$todo->assignedTo = 'admin';
|
||||
$todo->assignedBy = 'admin';
|
||||
$todo->assignedDate = date('Y-m-d', time());
|
||||
$todo->date = date('Y-m-d', time());
|
||||
|
||||
$todo->config = str_replace('2022-03-23', date('Y-m-d', time()), $todo->config);
|
||||
|
||||
$this->objectModel->createByCycle(array('1' => $todo));
|
||||
|
||||
global $tester;
|
||||
$objects = $tester->dao->select('id')->from(TABLE_TODO)->where('idvalue')->eq('100001')->andWhere('name')->eq($todo->name)->andWhere('config')->eq($todo->config)->andWhere('deleted')->eq('0')->fetchAll();
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return count($objects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test activate todo.
|
||||
*
|
||||
* @param int $todoID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function activateTest($todoID)
|
||||
{
|
||||
$this->objectModel->activate($todoID);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
$object = $this->objectModel->getById($todoID);
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test close a todo.
|
||||
*
|
||||
* @param int $todoID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function closeTest($todoID)
|
||||
{
|
||||
$this->objectModel->close($todoID);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
$object = $this->objectModel->getById($todoID);
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test assign todo.
|
||||
*
|
||||
* @param int $todoID
|
||||
* @param array $param
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function assignToTest($todoID, $param = array())
|
||||
{
|
||||
foreach($param as $key => $value) $_POST[$key] = $value;
|
||||
|
||||
if(!isset($_POST['future']) and !isset($_POST['date'])) $_POST['date'] = date('Y-m-d', time());
|
||||
|
||||
$this->objectModel->assignTo($todoID);
|
||||
|
||||
unset($_POST);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
$object = $this->objectModel->getById($todoID);
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get todo count.
|
||||
*
|
||||
* @param string $account
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function getCountTest($account = '')
|
||||
{
|
||||
$count = $this->objectModel->getCount($account);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -23,10 +23,11 @@ fields:
|
||||
format: ""
|
||||
- field: date
|
||||
note: "日期"
|
||||
range: "(M)-(w)"
|
||||
type: timestamp
|
||||
prefix: "DateTime"
|
||||
range: "(-1M)-(+1w):-1D"
|
||||
prefix: ""
|
||||
postfix: ""
|
||||
loop: 0
|
||||
type: timestamp
|
||||
format: "YY/MM/DD"
|
||||
- field: begin
|
||||
note: "开始"
|
||||
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->activate();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
激活一个状态为wait的todo >> wait
|
||||
激活一个状态为doing的todo >> wait
|
||||
激活一个状态为done的todo >> wait
|
||||
*/
|
||||
|
||||
$todoIDList = array('1', '2', '3');
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->activateTest($todoIDList[0])) && p('status') && e('wait'); // 激活一个状态为wait的todo
|
||||
r($todo->activateTest($todoIDList[1])) && p('status') && e('wait'); // 激活一个状态为doing的todo
|
||||
r($todo->activateTest($todoIDList[2])) && p('status') && e('wait'); // 激活一个状态为done的todo
|
||||
system("./ztest init");
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->assignTo();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
指派todo 1给test1 >> test1,20300101,1000,1400
|
||||
指派todo 2给test1 >> test1,2400,2400
|
||||
指派todo 3给test1 >> test1,1002,1402
|
||||
|
||||
*/
|
||||
|
||||
$todoIDList = array('1', '2', '3');
|
||||
|
||||
$todo1 = new stdclass();
|
||||
$todo1->assignedTo = 'test1';
|
||||
$todo1->future = 'on';
|
||||
$todo1->begin = 1000;
|
||||
$todo1->end = 1400;
|
||||
|
||||
$todo2 = new stdclass();
|
||||
$todo2->assignedTo = 'test1';
|
||||
$todo2->lblDisableDate = 'on';
|
||||
|
||||
$todo3 = new stdclass();
|
||||
$todo3->assignedTo = 'test1';
|
||||
$todo3->begin = 1002;
|
||||
$todo3->end = 1402;
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->assignToTest($todoIDList[0], $todo1)) && p('assignedTo,date,begin,end') && e('test1,20300101,1000,1400'); // 指派todo 1给test1
|
||||
r($todo->assignToTest($todoIDList[1], $todo2)) && p('assignedTo,begin,end') && e('test1,2400,2400'); // 指派todo 2给test1
|
||||
r($todo->assignToTest($todoIDList[2], $todo3)) && p('assignedTo,begin,end') && e('test1,1002,1402'); // 指派todo 3给test1
|
||||
system("./ztest init");
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->batchCreate();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
批量创建有个没有名字的待办 >> 批量创建待办1,desc1,1,custom,0;批量创建待办2,desc2,2,custom,0;批量创建待办3,desc4,4,custom,0
|
||||
批量创建的待办 >> 测试单转Bug13,desc1,1,bug,313;用户需求版本三41,desc2,2,story,1;开发任务11,desc3,3,task,1;测试单1,desc4,4,testtask,1
|
||||
|
||||
*/
|
||||
|
||||
$names = array('批量创建待办1','批量创建待办2','', '批量创建待办3', '', '', '', '');
|
||||
$types = array('custom', 'custom', 'custom', 'custom', 'custom', 'custom', 'custom', 'custom');
|
||||
$pris = array('1', '2', '3', '4', '1', '2', '3', '4');
|
||||
$descs = array('desc1', 'desc2', 'desc3', 'desc4', '' , '', '', '');
|
||||
$begins = array('0830', '0900', '0930', '1000', '1030', '1100', '1130', '1200');
|
||||
$ends = array('0900', '0930', '1000','1030', '1100', '1130', '1200', '1230');
|
||||
$bugs = array('2' => '313');
|
||||
|
||||
$noname_create = array('types' => $types, 'pris' => $pris, 'names' => $names, 'descs' => $descs, 'begins' => $begins, 'ends' => $ends);
|
||||
|
||||
$names = array('批量创建待办4','批量创建待办5','批量创建待办6', '批量创建待办7', '', '', '', '');
|
||||
$types = array('bug', 'story', 'task', 'testtask', 'custom', 'custom', 'custom', 'custom');
|
||||
$bugs = array('1' => '313');
|
||||
$stories = array('2' => '1');
|
||||
$tasks = array('3' => '1');
|
||||
$testtasks = array('4' => '1');
|
||||
|
||||
$except_create = array('types' => $types, 'pris' => $pris, 'names' => $names, 'descs' => $descs, 'begins' => $begins, 'ends' => $ends, 'bugs' => $bugs, 'stories' => $stories, 'tasks' => $tasks, 'testtasks' => $testtasks);
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->batchCreateTest($noname_create)) && p('2001:name,desc,pri,type,idvalue;2002:name,desc,pri,type,idvalue;2003:name,desc,pri,type,idvalue') && e(''); // 批量创建有个没有名字的待办
|
||||
r($todo->batchCreateTest($except_create)) && p('2004:name,desc,pri,type,idvalue;2005:name,desc,pri,type,idvalue;2006:name,desc,pri,type,idvalue;2007:name,desc,pri,type,idvalue') && e(''); // 批量创建的待办
|
||||
system("./ztest init");
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->batchUpdate();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
批量修改todo类型 >> type,task,custom
|
||||
批量修改todo优先级 >> pri,2,1
|
||||
批量修改todo状态 >> status,wait,doing
|
||||
|
||||
*/
|
||||
|
||||
$types = array('1' => 'custom', '2' => 'bug', '3' => 'custom');
|
||||
$pris = array('1' => '1', '2' => '1', '3' => '3');
|
||||
$status = array('1' => 'doing', '2' => 'doing', '3' => 'done');
|
||||
$bugs = array('2' => '1');
|
||||
$tasks = array('3' => '2');
|
||||
|
||||
$changeType = array('types' => $types, 'bugs' => $bugs);
|
||||
$changePri = array('pris' => $pris, 'bugs' => $bugs, 'tasks' => $tasks);
|
||||
$changeStatus = array('status' => $status, 'bugs' => $bugs, 'tasks' => $tasks);
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->batchUpdateTest($changeType, '3')) && p('0:field,old,new') && e('type,task,custom'); // 批量修改todo类型
|
||||
r($todo->batchUpdateTest($changePri, '2')) && p('0:field,old,new') && e('pri,2,1'); // 批量修改todo优先级
|
||||
r($todo->batchUpdateTest($changeStatus, '1')) && p('0:field,old,new') && e('status,wait,doing'); // 批量修改todo状态
|
||||
system("./ztest init");
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->close();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
关闭一个状态为wait的todo >> closed
|
||||
关闭一个状态为doing的todo >> closed
|
||||
关闭一个状态为done的todo >> closed
|
||||
|
||||
*/
|
||||
|
||||
$todoIDList = array('1', '2', '3');
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->closeTest($todoIDList[0])) && p('status') && e('closed'); // 关闭一个状态为wait的todo
|
||||
r($todo->closeTest($todoIDList[1])) && p('status') && e('closed'); // 关闭一个状态为doing的todo
|
||||
r($todo->closeTest($todoIDList[2])) && p('status') && e('closed'); // 关闭一个状态为done的todo
|
||||
system("./ztest init");
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->create();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
创建没有名字的待办 >> 『待办名称』不能为空。
|
||||
创建自定义待办 >> 时间待定的月周期待办,custom,wait
|
||||
创建bug待办 >> 测试单转Bug13,bug,doing
|
||||
创建task待办 >> 开发任务11,task,done
|
||||
创建story待办 >> 用户需求1,story,closed
|
||||
|
||||
*/
|
||||
|
||||
$accountList = array('admin', 'dev1', 'test1');
|
||||
|
||||
$b_noname = new stdclass();
|
||||
$b_noname->name = '';
|
||||
$b_noname->date = 'today';
|
||||
$b_noname->type = 'custom';
|
||||
|
||||
$todo1 = new stdclass();
|
||||
$todo1->name = '时间待定的月周期待办';
|
||||
$todo1->type = 'custom';
|
||||
$todo1->date = '+3 days';
|
||||
$todo1->config = array('day' => '', 'specify' => array('month' => 0, 'day' => 1), 'month' => array(1,3,5), 'type' => 'month', 'beforeDays' => 2, 'end' => '2025-01-01');
|
||||
|
||||
$todo2 = new stdclass();
|
||||
$todo2->name = 'bug待办';
|
||||
$todo2->type = 'bug';
|
||||
$todo2->date = 'today';
|
||||
$todo2->bug = '313';
|
||||
$todo2->status = 'doing';
|
||||
$todo2->uid = '313';
|
||||
|
||||
$todo3 = new stdclass();
|
||||
$todo3->name = 'task待办';
|
||||
$todo3->type = 'task';
|
||||
$todo3->date = 'today';
|
||||
$todo3->task = '1';
|
||||
$todo3->status = 'done';
|
||||
$todo3->uid = '1';
|
||||
|
||||
$todo4 = new stdclass();
|
||||
$todo4->name = 'story待办';
|
||||
$todo4->type = 'story';
|
||||
$todo4->date = 'today';
|
||||
$todo4->story = '1';
|
||||
$todo4->status = 'closed';
|
||||
$todo4->uid = '1';
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->createTest($accountList[0], $b_noname)) && p() && e('『待办名称』不能为空。'); //创建没有名字的待办
|
||||
r($todo->createTest($accountList[1], $todo1)) && p('name,type,status') && e('时间待定的月周期待办,custom,wait'); //创建自定义待办
|
||||
r($todo->createTest($accountList[2], $todo2)) && p('name,type,status') && e('测试单转Bug13,bug,doing'); //创建bug待办
|
||||
r($todo->createTest($accountList[0], $todo3)) && p('name,type,status') && e('开发任务11,task,done'); //创建task待办
|
||||
r($todo->createTest($accountList[0], $todo4)) && p('name,type,status') && e('用户需求1,story,closed'); //创建story待办
|
||||
system("./ztest init");
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->createByCycle();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
$todo1 = new stdclass();
|
||||
$todo1->name = 'cycle生成的待办1';
|
||||
$todo1->config = '{"specify":{"month":"0","day":"1"},"days":"1","type":"day","beforeDays":11,"end":"","begin":"2022-03-23"}';
|
||||
|
||||
$todo2 = new stdclass();
|
||||
$todo2->name = 'cycle生成的待办2';
|
||||
$todo2->config = '{"specify":{"month":"0","day":"1"},"week":"2,4,7","type":"week","beforeDays":31,"end":"","begin":"2022-03-23"}';
|
||||
|
||||
$todo3 = new stdclass();
|
||||
$todo3->name = 'cycle生成的待办3';
|
||||
$todo3->config = '{"specify":{"month":"0","day":"1"},"month":"1,8,13,15,27,29,30","type":"month","beforeDays":301,"end":"","begin":"2022-03-23"}';
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->createByCycleTest($todo1)) && p() && e('');
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->finish();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
结束一个状态为wait的todo >> done
|
||||
结束一个状态为doing的todo >> done
|
||||
结束一个状态为done的todo >> done
|
||||
|
||||
*/
|
||||
|
||||
$todoIDList = array('1', '2', '3');
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->finishTest($todoIDList[0])) && p('status') && e('done'); // 结束一个状态为wait的todo
|
||||
r($todo->finishTest($todoIDList[1])) && p('status') && e('done'); // 结束一个状态为doing的todo
|
||||
r($todo->finishTest($todoIDList[2])) && p('status') && e('done'); // 结束一个状态为done的todo
|
||||
system("./ztest init");
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->getById();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取id为1的todo信息 >> 自定义1的待办,custom,wait
|
||||
获取id为2的todo信息 >> BUG1,bug,doing
|
||||
获取id为3的todo信息 >> 开发任务12,task,done
|
||||
获取id为4的todo信息 >> 用户需求3,story,closed
|
||||
获取id不存在的todo信息 >> 0
|
||||
|
||||
*/
|
||||
|
||||
$todoIDList = array('1', '2', '3', '4', '100001');
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->getByIdTest($todoIDList[0])) && p('name,type,status') && e('自定义1的待办,custom,wait'); // 获取id为1的todo信息
|
||||
r($todo->getByIdTest($todoIDList[1])) && p('name,type,status') && e('BUG1,bug,doing'); // 获取id为2的todo信息
|
||||
r($todo->getByIdTest($todoIDList[2])) && p('name,type,status') && e('开发任务12,task,done'); // 获取id为3的todo信息
|
||||
r($todo->getByIdTest($todoIDList[3])) && p('name,type,status') && e('用户需求3,story,closed'); // 获取id为4的todo信息
|
||||
r($todo->getByIdTest($todoIDList[4])) && p('name,type,status') && e('0'); // 获取id不存在的todo信息
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->getByList();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取todo 1 2 3 4的名称 >> 自定义1的待办,BUG2的待办,任务3的待办,需求4的待办
|
||||
获取todo 5 6 7 8的名称 >> 测试单5的待办,自定义6的待办,BUG7的待办,任务8的待办
|
||||
获取todo 9 10 11 12的名称 >> 需求9的待办,测试单10的待办,自定义11的待办,BUG12的待办
|
||||
|
||||
*/
|
||||
|
||||
$todoIDList1 = array('1', '2', '3', '4');
|
||||
$todoIDList2 = array('5', '6', '7', '8');
|
||||
$todoIDList3 = array('9', '10', '11', '12');
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->getByListTest($todoIDList1)) && p() && e('自定义1的待办,BUG2的待办,任务3的待办,需求4的待办'); // 获取todo 1 2 3 4的名称
|
||||
r($todo->getByListTest($todoIDList2)) && p() && e('测试单5的待办,自定义6的待办,BUG7的待办,任务8的待办'); // 获取todo 5 6 7 8的名称
|
||||
r($todo->getByListTest($todoIDList3)) && p() && e('需求9的待办,测试单10的待办,自定义11的待办,BUG12的待办'); // 获取todo 9 10 11 12的名称
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->getCount();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取用户admin的所有待办个数 >> 2
|
||||
获取用户user1的所有待办个数 >> 2
|
||||
获取用户user2的所有待办个数 >> 2
|
||||
获取用户user3的所有待办个数 >> 2
|
||||
获取不存在的用户所有待办个数 >> 0
|
||||
|
||||
*/
|
||||
|
||||
$accountList = array('admin', 'user1', 'user2', 'user3', 'user10001');
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->getCountTest($accountList[0])) && p() && e('2'); // 获取用户admin的所有待办个数
|
||||
r($todo->getCountTest($accountList[1])) && p() && e('2'); // 获取用户user1的所有待办个数
|
||||
r($todo->getCountTest($accountList[2])) && p() && e('2'); // 获取用户user2的所有待办个数
|
||||
r($todo->getCountTest($accountList[3])) && p() && e('2'); // 获取用户user3的所有待办个数
|
||||
r($todo->getCountTest($accountList[4])) && p() && e('0'); // 获取不存在的用户所有待办个数
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->getList();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
获取type为today 当前用户的代办数量 >> 0
|
||||
获取type为yesterday 当前用户的代办数量 >> 0
|
||||
获取type为thisweek 当前用户的代办数量 >> 0
|
||||
获取type为lastweek 当前用户的代办数量 >> 1
|
||||
获取type为thismonth 当前用户的代办数量 >> 1
|
||||
获取type为lastmonth 当前用户的代办数量 >> 1
|
||||
获取type为thisseason 当前用户的代办数量 >> 2
|
||||
获取type为thisyear 当前用户的代办数量 >> 2
|
||||
获取type为future 当前用户的代办数量 >> 0
|
||||
获取type为before 当前用户的代办数量 >> 2
|
||||
获取type为cycle 当前用户的代办数量 >> 0
|
||||
获取type为today user1的代办数量 >> 0
|
||||
获取type为yesterday user1的代办数量 >> 0
|
||||
获取type为thisweek user1的代办数量 >> 0
|
||||
获取type为lastweek user1的代办数量 >> 1
|
||||
获取type为thismonth user1的代办数量 >> 1
|
||||
获取type为lastmonth user1的代办数量 >> 1
|
||||
获取type为thisseason user1的代办数量 >> 2
|
||||
获取type为thisyear user1的代办数量 >> 2
|
||||
获取type为future user1的代办数量 >> 0
|
||||
获取type为before user1的代办数量 >> 2
|
||||
获取type为cycle user1的代办数量 >> 0
|
||||
|
||||
*/
|
||||
|
||||
$typeList = array('today', 'yesterday', 'thisweek', 'lastweek', 'thismonth', 'lastmonth', 'thisseason', 'thisyear', 'future', 'before', 'cycle');
|
||||
$account = 'user1';
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->getListTest($typeList[0])) && p() && e('0'); // 获取type为today 当前用户的代办数量
|
||||
r($todo->getListTest($typeList[1])) && p() && e('0'); // 获取type为yesterday 当前用户的代办数量
|
||||
r($todo->getListTest($typeList[2])) && p() && e('0'); // 获取type为thisweek 当前用户的代办数量
|
||||
r($todo->getListTest($typeList[3])) && p() && e('1'); // 获取type为lastweek 当前用户的代办数量
|
||||
r($todo->getListTest($typeList[4])) && p() && e('1'); // 获取type为thismonth 当前用户的代办数量
|
||||
r($todo->getListTest($typeList[5])) && p() && e('1'); // 获取type为lastmonth 当前用户的代办数量
|
||||
r($todo->getListTest($typeList[6])) && p() && e('2'); // 获取type为thisseason 当前用户的代办数量
|
||||
r($todo->getListTest($typeList[7])) && p() && e('2'); // 获取type为thisyear 当前用户的代办数量
|
||||
r($todo->getListTest($typeList[8])) && p() && e('0'); // 获取type为future 当前用户的代办数量
|
||||
r($todo->getListTest($typeList[9])) && p() && e('2'); // 获取type为before 当前用户的代办数量
|
||||
r($todo->getListTest($typeList[10])) && p() && e('0'); // 获取type为cycle 当前用户的代办数量
|
||||
r($todo->getListTest($typeList[0], $account)) && p() && e('0'); // 获取type为today user1的代办数量
|
||||
r($todo->getListTest($typeList[1], $account)) && p() && e('0'); // 获取type为yesterday user1的代办数量
|
||||
r($todo->getListTest($typeList[2], $account)) && p() && e('0'); // 获取type为thisweek user1的代办数量
|
||||
r($todo->getListTest($typeList[3], $account)) && p() && e('1'); // 获取type为lastweek user1的代办数量
|
||||
r($todo->getListTest($typeList[4], $account)) && p() && e('1'); // 获取type为thismonth user1的代办数量
|
||||
r($todo->getListTest($typeList[5], $account)) && p() && e('1'); // 获取type为lastmonth user1的代办数量
|
||||
r($todo->getListTest($typeList[6], $account)) && p() && e('2'); // 获取type为thisseason user1的代办数量
|
||||
r($todo->getListTest($typeList[7], $account)) && p() && e('2'); // 获取type为thisyear user1的代办数量
|
||||
r($todo->getListTest($typeList[8], $account)) && p() && e('0'); // 获取type为future user1的代办数量
|
||||
r($todo->getListTest($typeList[9], $account)) && p() && e('2'); // 获取type为before user1的代办数量
|
||||
r($todo->getListTest($typeList[10], $account)) && p() && e('0'); // 获取type为cycle user1的代办数量
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->start();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
开始一个状态为wait的todo >> doing
|
||||
开始一个状态为doing的todo >> doing
|
||||
开始一个状态为done的todo >> doing
|
||||
|
||||
*/
|
||||
|
||||
$todoIDList = array('1', '2', '3');
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->startTest($todoIDList[0])) && p('status') && e('doing'); // 开始一个状态为wait的todo
|
||||
r($todo->startTest($todoIDList[1])) && p('status') && e('doing'); // 开始一个状态为doing的todo
|
||||
r($todo->startTest($todoIDList[2])) && p('status') && e('doing'); // 开始一个状态为done的todo
|
||||
system("./ztest init");
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/todo.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 todoModel->update();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
测试更新todo名称 >> name,自定义1的待办,john
|
||||
测试更新todo类型 >> type,custom,bug
|
||||
测试更新todo名称和类型 >> type,bug,custom;name,BUG2的待办,jack
|
||||
测试不更新todo任何数据 >> 没有数据更新
|
||||
|
||||
*/
|
||||
|
||||
$todoIDList = array('1', '2');
|
||||
|
||||
$t_upname = array('name' => 'john');
|
||||
$t_uptype = array('type' => 'bug', 'idvalue' => '1');
|
||||
$t_typename = array('name' => 'jack', 'type' => 'custom');
|
||||
$t_unname = array('name' => 'john');
|
||||
|
||||
|
||||
$todo = new todoTest();
|
||||
|
||||
r($todo->updateTest($todoIDList[0], $t_upname)) && p('0:field,old,new') && e('name,自定义1的待办,john'); // 测试更新todo名称
|
||||
r($todo->updateTest($todoIDList[0], $t_uptype)) && p('0:field,old,new') && e('type,custom,bug'); // 测试更新todo类型
|
||||
r($todo->updateTest($todoIDList[1], $t_typename)) && p('0:field,old,new;1:field,old,new') && e('type,bug,custom;name,BUG2的待办,jack'); // 测试更新todo名称和类型
|
||||
r($todo->updateTest($todoIDList[0], $t_unname)) && p() && e('没有数据更新'); // 测试不更新todo任何数据
|
||||
system("./ztest init");
|
||||
@@ -43,6 +43,9 @@ switch($argv[1])
|
||||
case 'company':
|
||||
ztfRun('model/company');
|
||||
break;
|
||||
case 'todo':
|
||||
ztfRun('model/todo');
|
||||
break;
|
||||
case 'model':
|
||||
ztfRun('model');
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user