* [misc] Fix unittest error of the myModel::buildTaskSearchForm method.
This commit is contained in:
@@ -269,16 +269,14 @@ class myTest
|
||||
*
|
||||
* @param int $queryID
|
||||
* @param string $actionURL
|
||||
* @param string $rawMethod
|
||||
* @param bool $cacheSearchParams
|
||||
* @access public
|
||||
* @return array
|
||||
* @return null|array
|
||||
*/
|
||||
public function buildTaskSearchFormTest(int $queryID, string $actionURL): array
|
||||
public function buildTaskSearchFormTest(int $queryID, string $actionURL, string $rawMethod, bool $cacheSearchParams): null|array
|
||||
{
|
||||
$this->objectModel->buildTaskSearchForm($queryID, $actionURL);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
global $tester;
|
||||
return $tester->config->execution->search;
|
||||
return $this->objectModel->buildTaskSearchForm($queryID, $actionURL, $rawMethod, $cacheSearchParams);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,18 @@ declare(strict_types=1);
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/my.unittest.class.php';
|
||||
|
||||
zenData('user')->gen('1');
|
||||
zenData('user')->gen(1);
|
||||
|
||||
$execution = zenData('project');
|
||||
$execution->id->range('1-5');
|
||||
$execution->name->range('项目1,项目2,迭代1,迭代2,迭代3');
|
||||
$execution->type->range('project{2},sprint,stage,kanban');
|
||||
$execution->path->range('1,2,`1,3`,`1,4`,`2,5`')->prefix(',')->postfix(',');
|
||||
$execution->gen(5);
|
||||
|
||||
$module = zenData('module');
|
||||
$module->name->range('1,2,3,4,5')->prefix('模块');
|
||||
$module->gen(5);
|
||||
|
||||
su('admin');
|
||||
|
||||
@@ -14,22 +25,52 @@ title=测试 myModel->buildTaskSearchForm();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 测试获取queryID 1 actionURL actionURL1 的搜索表单
|
||||
- 属性module @Task
|
||||
- 属性queryID @0
|
||||
- 属性actionURL @actionURL1
|
||||
- 测试获取queryID 0 actionURL actionURL2 的搜索表单
|
||||
- 属性module @Task
|
||||
- 属性queryID @1
|
||||
- 属性actionURL @actionURL2
|
||||
|
||||
*/
|
||||
|
||||
$my = new myTest();
|
||||
$queryID = 1;
|
||||
$rawMethod = 'contribute';
|
||||
$actionURL = "/my-{$rawMethod}-task.html";
|
||||
$my = new myTest();
|
||||
|
||||
$queryID = array(0, 1);
|
||||
$actionURL = array('actionURL1', 'actionURL2');
|
||||
$config1 = $my->buildTaskSearchFormTest($queryID[0], $actionURL[0]);
|
||||
$config2 = $my->buildTaskSearchFormTest($queryID[1], $actionURL[1]);
|
||||
r($config1) && p('module,queryID,actionURL') && e('Task,0,actionURL1'); // 测试获取queryID 1 actionURL actionURL1 的搜索表单
|
||||
r($config2) && p('module,queryID,actionURL') && e('Task,1,actionURL2'); // 测试获取queryID 0 actionURL actionURL2 的搜索表单
|
||||
$searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $rawMethod, true);
|
||||
r(isset($searchConfig['module'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 module 为空。
|
||||
r(isset($searchConfig['queryID'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 queryID 为空。
|
||||
r(isset($searchConfig['actionURL'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 actionURL 为空。
|
||||
r(isset($searchConfig['fields'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 fields 为空。
|
||||
r(isset($searchConfig['params'])) && p() && e(0); // 缓存查询参数,rawMethod 为 contribute,查询参数中 params 为空。
|
||||
|
||||
$searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $rawMethod, false);
|
||||
r(isset($searchConfig['module'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询参数中 module 不为空。
|
||||
r(isset($searchConfig['queryID'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询参数中 queryID 不为空。
|
||||
r(isset($searchConfig['actionURL'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询参数中 actionURL 不为空。
|
||||
r(isset($searchConfig['fields']['closedReason'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedReason 不为空。
|
||||
r(isset($searchConfig['fields']['closedBy'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedBy 不为空。
|
||||
r(isset($searchConfig['fields']['closedDate'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 closedDate 不为空。
|
||||
r(isset($searchConfig['fields']['canceledBy'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 canceledBy 不为空。
|
||||
r(isset($searchConfig['fields']['canceledDate'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 contribute,查询字段中 canceledDate 不为空。
|
||||
|
||||
r($searchConfig) && p('module') && e('contributeTask'); // 不缓存查询参数,rawMethod 为 contribute,打印 module 的值。
|
||||
r($searchConfig) && p('queryID') && e('1'); // 不缓存查询参数,rawMethod 为 contribute,打印 queryID 的值。
|
||||
r($searchConfig) && p('actionURL') && e('/my-contribute-task.html'); // 不缓存查询参数,rawMethod 为 contribute,打印 actionURL 的值。
|
||||
r($searchConfig['params']['project']['values']) && p('1,2,all') && e('项目1,项目2,所有项目'); // 不缓存查询参数,rawMethod 为 contribute,打印所属项目列表。
|
||||
r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('/迭代1,/迭代2,/迭代3,所有执行'); // 不缓存查询参数,rawMethod 为 contribute,打印所属执行列表。
|
||||
r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('/,~~,/模块2,~~,~~,/模块5'); // 不缓存查询参数,rawMethod 为 contribute,打印所属模块列表。
|
||||
|
||||
$rawMethod = 'work';
|
||||
$actionURL = "/my-{$rawMethod}-task.html";
|
||||
$searchConfig = $my->buildTaskSearchFormTest($queryID, $actionURL, $rawMethod, false);
|
||||
r(isset($searchConfig['module'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 work,查询参数中 module 不为空。
|
||||
r(isset($searchConfig['queryID'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 work,查询参数中 queryID 不为空。
|
||||
r(isset($searchConfig['actionURL'])) && p() && e(1); // 不缓存查询参数,rawMethod 为 work,查询参数中 actionURL 不为空。
|
||||
r(isset($searchConfig['fields']['closedReason'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 closedReason 为空。
|
||||
r(isset($searchConfig['fields']['closedBy'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 closedBy 为空。
|
||||
r(isset($searchConfig['fields']['closedDate'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 closedDate 为空。
|
||||
r(isset($searchConfig['fields']['canceledBy'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 canceledBy 为空。
|
||||
r(isset($searchConfig['fields']['canceledDate'])) && p() && e(0); // 不缓存查询参数,rawMethod 为 work,查询字段中 canceledDate 为空。
|
||||
|
||||
r($searchConfig) && p('module') && e('workTask'); // 不缓存查询参数,rawMethod 为 work,打印 module 的值。
|
||||
r($searchConfig) && p('queryID') && e('1'); // 不缓存查询参数,rawMethod 为 work,打印 queryID 的值。
|
||||
r($searchConfig) && p('actionURL') && e('/my-work-task.html'); // 不缓存查询参数,rawMethod 为 work,打印 actionURL 的值。
|
||||
r($searchConfig['params']['project']['values']) && p('1,2,all') && e('项目1,项目2,所有项目'); // 不缓存查询参数,rawMethod 为 work,打印所属项目列表。
|
||||
r($searchConfig['params']['execution']['values']) && p('3,4,5,all') && e('/迭代1,/迭代2,/迭代3,所有执行'); // 不缓存查询参数,rawMethod 为 work,打印所属执行列表。
|
||||
r($searchConfig['params']['module']['values']) && p('0,1,2,3,4,5') && e('/,~~,/模块2,~~,~~,/模块5'); // 不缓存查询参数,rawMethod 为 work,打印所属模块列表。
|
||||
|
||||
Reference in New Issue
Block a user