* Refactor testcaseModel::getSceneMenu, rename buildMenuQuery to getScenesForMenu, and modify unit test.
This commit is contained in:
+22
-41
@@ -1597,19 +1597,20 @@ class testcaseModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建菜单查询。
|
||||
* Build menu query.
|
||||
* 为构建场景菜单获取场景。
|
||||
* Get scenes for menu.
|
||||
*
|
||||
* @param int $rootID
|
||||
* @param int $productID
|
||||
* @param int $moduleID
|
||||
* @param int $startScene
|
||||
* @param string $branch
|
||||
* @param int $currentScene
|
||||
* @access public
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function buildMenuQuery(int $rootID, int $moduleID, int $startScene = 0, string $branch = 'all'): string
|
||||
public function getScenesForMenu(int $productID, int $moduleID, int $startScene = 0, string $branch = 'all', int $currentScene = 0): array
|
||||
{
|
||||
/* Set the start module. */
|
||||
/* Set the start scene. */
|
||||
$startScenePath = '';
|
||||
if($startScene > 0)
|
||||
{
|
||||
@@ -1617,15 +1618,16 @@ class testcaseModel extends model
|
||||
if($startScene) $startScenePath = $startScene->path . '%';
|
||||
}
|
||||
|
||||
/* Return scene query. */
|
||||
/* Return scenes. */
|
||||
return $this->dao->select('*')->from(TABLE_SCENE)
|
||||
->where('deleted')->eq(0)
|
||||
->beginIF($rootID)->andWhere('product')->eq($rootID)->fi()
|
||||
->andWhere('id')->ne($currentScene)
|
||||
->beginIF($productID)->andWhere('product')->eq($productID)->fi()
|
||||
->beginIF($moduleID > 0)->andWhere('module')->eq($moduleID)->fi()
|
||||
->beginIF($startScenePath)->andWhere('path')->like($startScenePath)->fi()
|
||||
->beginIF($branch !== 'all' and $branch !== '' and $branch !== false)->andWhere('branch')->eq((int)$branch)->fi()
|
||||
->beginIF($branch !== 'all' && $branch !== '')->andWhere('branch')->eq((int)$branch)->fi()
|
||||
->orderBy('grade desc, sort')
|
||||
->get();
|
||||
->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1646,10 +1648,8 @@ class testcaseModel extends model
|
||||
{
|
||||
if(empty($parentSceneID)) continue;
|
||||
if(empty($scenes[$parentSceneID])) continue;
|
||||
|
||||
$sceneName .= $scenes[$parentSceneID]->title . '/';
|
||||
}
|
||||
|
||||
$sceneName = rtrim($sceneName, '/');
|
||||
$sceneName .= "|$scene->id\n";
|
||||
|
||||
@@ -1872,11 +1872,11 @@ class testcaseModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取场景菜单。
|
||||
* Get scene menu.
|
||||
*
|
||||
* @param int $rootID
|
||||
* @param int $productID
|
||||
* @param int $moduleID
|
||||
* @param string $type
|
||||
* @param int $startScene
|
||||
* @param int $branch
|
||||
* @param int $currentScene
|
||||
@@ -1884,31 +1884,20 @@ class testcaseModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getSceneMenu($rootID, $moduleID, $type = '', $startScene = 0, $branch = 0, $currentScene = 0, $emptyMenu = false)
|
||||
public function getSceneMenu(int $productID, int $moduleID, int $startScene = 0, int|string $branch = 0, int $currentScene = 0, bool $emptyMenu = false): array
|
||||
{
|
||||
if(empty($branch)) $branch = 0;
|
||||
|
||||
/* If type of $branch is array, get scenes of these branches. */
|
||||
if(is_array($branch))
|
||||
{
|
||||
$scenes = array();
|
||||
foreach($branch as $branchID) $scenes[$branchID] = $this->getOptionMenu($rootID,$moduleID, $type, $startScene, $branchID,$currentScene);
|
||||
|
||||
return $scenes;
|
||||
}
|
||||
|
||||
if($type == 'line') $rootID = 0;
|
||||
|
||||
$branches = array($branch => '');
|
||||
if($branch != 'all' and strpos('story|bug|case', $type) !== false)
|
||||
if($branch != 'all')
|
||||
{
|
||||
$product = $this->loadModel('product')->getById($rootID);
|
||||
if($product and $product->type != 'normal')
|
||||
$product = $this->loadModel('product')->getById($productID);
|
||||
if($product && $product->type != 'normal')
|
||||
{
|
||||
$branchPairs = $this->loadModel('branch')->getPairs($rootID, 'all');
|
||||
$branchPairs = $this->loadModel('branch')->getPairs($productID, 'all');
|
||||
$branches = array($branch => $branchPairs[$branch]);
|
||||
}
|
||||
elseif($product and $product->type == 'normal')
|
||||
elseif($product && $product->type == 'normal')
|
||||
{
|
||||
$branches = array(0 => '');
|
||||
}
|
||||
@@ -1917,17 +1906,10 @@ class testcaseModel extends model
|
||||
$treeMenu = array();
|
||||
foreach($branches as $branchID => $branch)
|
||||
{
|
||||
$scenes = array();
|
||||
$stmt = $this->dbh->query($this->buildMenuQuery($rootID, $moduleID, $startScene, $branchID));
|
||||
while($scene = $stmt->fetch())
|
||||
{
|
||||
if ($scene->id != $currentScene) $scenes[$scene->id] = $scene;
|
||||
}
|
||||
|
||||
$scenes = $this->getScenesForMenu($productID, $moduleID, $startScene, $branchID, $currentScene);
|
||||
foreach($scenes as $scene)
|
||||
{
|
||||
$branchName = (!empty($product) and $product->type != 'normal' and $scene->branch === BRANCH_MAIN) ? $this->lang->branch->main : $branch;
|
||||
|
||||
$branchName = !empty($product) && $product->type != 'normal' && $scene->branch === BRANCH_MAIN ? $this->lang->branch->main : $branch;
|
||||
$this->buildTreeArray($treeMenu, $scenes, $scene, (empty($branchName)) ? '/' : "/$branchName/");
|
||||
}
|
||||
}
|
||||
@@ -1945,7 +1927,6 @@ class testcaseModel extends model
|
||||
|
||||
/* Attach empty option. */
|
||||
if($emptyMenu) $lastMenu['null'] = $this->lang->null;
|
||||
|
||||
return $lastMenu;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/testcase.class.php';
|
||||
|
||||
zdTable('scene')->config('modulescene')->gen('170');
|
||||
zdTable('user')->gen('1');
|
||||
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 testcaseModel->buildMenuQuery();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
$productIdList = array(0, 1, 2, 41);
|
||||
$moduleIdList = array(0, 1821, 1825);
|
||||
$sceneIdList = array(0, 1, 6, 161);
|
||||
$branchIdList = array('all', '', '0');
|
||||
|
||||
$testcase = new testcaseTest();
|
||||
|
||||
r($testcase->buildMenuQueryTest($productIdList[0], $moduleIdList[0], $sceneIdList[0])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' ORDER BY `grade` desc,`sort`"); // 测试获取产品 0 模块 0 起始场景 0 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[0], $moduleIdList[0], $sceneIdList[0], $branchIdList[0])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' ORDER BY `grade` desc,`sort`"); // 测试获取产品 0 模块 0 起始场景 0 分支 all 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[0], $moduleIdList[0], $sceneIdList[0], $branchIdList[1])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' ORDER BY `grade` desc,`sort`"); // 测试获取产品 0 模块 0 起始场景 0 分支 '' 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[0], $moduleIdList[0], $sceneIdList[0], $branchIdList[2])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `branch` = '0' ORDER BY `grade` desc,`sort`"); // 测试获取产品 0 模块 0 起始场景 0 分支 0 的查询语句
|
||||
|
||||
r($testcase->buildMenuQueryTest($productIdList[0], $moduleIdList[0], $sceneIdList[1])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `path` LIKE '%' ORDER BY `grade` desc,`sort`"); // 测试获取产品 0 模块 0 起始场景 1 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[0], $moduleIdList[0], $sceneIdList[1], $branchIdList[2])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `path` LIKE '%' AND `branch` = '0' ORDER BY `grade` desc,`sort`"); // 测试获取产品 0 模块 0 起始场景 1 分支 0 的查询语句
|
||||
|
||||
r($testcase->buildMenuQueryTest($productIdList[0], $moduleIdList[0], $sceneIdList[2])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `path` LIKE '%' ORDER BY `grade` desc,`sort`"); // 测试获取产品 0 模块 0 起始场景 6 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[0], $moduleIdList[0], $sceneIdList[2], $branchIdList[2])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `path` LIKE '%' AND `branch` = '0' ORDER BY `grade` desc,`sort`"); // 测试获取产品 0 模块 0 起始场景 6 分支 0 的查询语句
|
||||
|
||||
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[0], $sceneIdList[0])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' ORDER BY `grade` desc,`sort`"); // 测试获取产品 1 模块 0 起始场景 0 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[0])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' ORDER BY `grade` desc,`sort`"); // 测试获取产品 1 模块 0 起始场景 0 分支 all 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[1])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' ORDER BY `grade` desc,`sort`"); // 测试获取产品 1 模块 0 起始场景 0 分支 '' 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[2])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' AND `branch` = '0' ORDER BY `grade` desc,`sort`"); // 测试获取产品 1 模块 0 起始场景 0 分支 0 的查询语句
|
||||
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[0], $sceneIdList[1])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' AND `path` LIKE '%' ORDER BY `grade` desc,`sort`"); // 测试获取产品 1 模块 0 起始场景 1 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[0], $sceneIdList[1], $branchIdList[2])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' AND `path` LIKE '%' AND `branch` = '0' ORDER BY `grade` desc,`sort`"); // 测试获取产品 1 模块 0 起始场景 1 分支 0 的查询语句
|
||||
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[1], $sceneIdList[1])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' AND `module` = '1821' AND `path` LIKE '%' ORDER BY `grade` desc,`sort`"); // 测试获取产品 1 模块 1821 起始场景 1 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[1], $sceneIdList[1], $branchIdList[2])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' AND `module` = '1821' AND `path` LIKE '%' AND `branch` = '0' ORDER BY `grade` desc,`sort`"); // 测试获取产品 1 模块 1821 起始场景 1 分支 0 的查询语句
|
||||
|
||||
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[0], $sceneIdList[0])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' ORDER BY `grade` desc,`sort`"); // 测试获取产品 41 模块 0 起始场景 0 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[0])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' ORDER BY `grade` desc,`sort`"); // 测试获取产品 41 模块 0 起始场景 0 分支 all 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[1])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' ORDER BY `grade` desc,`sort`"); // 测试获取产品 41 模块 0 起始场景 0 分支 '' 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[2])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' AND `branch` = '0' ORDER BY `grade` desc,`sort`"); // 测试获取产品 41 模块 0 起始场景 0 分支 0 的查询语句
|
||||
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[0], $sceneIdList[1])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' AND `path` LIKE '%' ORDER BY `grade` desc,`sort`"); // 测试获取产品 41 模块 0 起始场景 161 的查询语句
|
||||
r($testcase->buildMenuQueryTest($productIdList[1], $moduleIdList[0], $sceneIdList[1], $branchIdList[2])) && p() && e("SELECT * FROM `zt_scene` WHERE `deleted` = '0' AND `product` = '1' AND `path` LIKE '%' AND `branch` = '0' ORDER BY `grade` desc,`sort`"); // 测试获取产品 41 模块 0 起始场景 161 分支 0 的查询语句
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/testcase.class.php';
|
||||
|
||||
zdTable('scene')->config('moduletreescene')->gen('20');
|
||||
zdTable('user')->gen('1');
|
||||
|
||||
su('admin');
|
||||
|
||||
global $tester;
|
||||
$scenes = $tester->dao->update(TABLE_SCENE)->set("path= replace(`path`,',0,', ',')")->exec();
|
||||
$scenes = $tester->dao->update(TABLE_SCENE)->set("path= replace(`path`,',0,', ',')")->exec();
|
||||
|
||||
/**
|
||||
|
||||
title=测试 testcaseModel->getSceneMenu();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
$productIdList = array(1, 41);
|
||||
$moduleIdList = array(0, 1, 2);
|
||||
$sceneIdList = array(0, 6, 16);
|
||||
$branchIdList = array('all', '0', 1);
|
||||
$currentScene = array(0, 6, 16);
|
||||
$emptyMenu = array(false, true);
|
||||
|
||||
$testcase = new testcaseTest();
|
||||
|
||||
r($testcase->getSceneMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[0], $branchIdList[0], $currentScene[0], $emptyMenu[0])) && p() && e('/,/场景1,/场景1/场景2,/场景3,/场景4,/场景5,/场景6,/场景6/场景7,/场景6/场景7/场景8,/场景9,/场景10'); // 测试获取产品 1 模块 0 起始场景 0 分支 all 当前场景 0 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[0], $moduleIdList[1], $sceneIdList[0], $branchIdList[0], $currentScene[0], $emptyMenu[0])) && p() && e('/,/场景6,/场景6/场景7,/场景6/场景7/场景8,/场景9,/场景10'); // 测试获取产品 1 模块 1 起始场景 0 分支 all 当前场景 0 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[1], $branchIdList[0], $currentScene[0], $emptyMenu[0])) && p() && e('/,/场景6,/场景6/场景7,/场景6/场景7/场景8'); // 测试获取产品 1 模块 0 起始场景 6 分支 all 当前场景 0 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[0], $branchIdList[1], $currentScene[0], $emptyMenu[0])) && p() && e('/,/场景1,/场景1/场景2,/场景3,/场景4,/场景5,/场景6,/场景6/场景7,/场景6/场景7/场景8,/场景9,/场景10'); // 测试获取产品 1 模块 0 起始场景 0 分支 '0' 当前场景 0 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[0], $branchIdList[2], $currentScene[0], $emptyMenu[0])) && p() && e('/,/场景1,/场景1/场景2,/场景3,/场景4,/场景5,/场景6,/场景6/场景7,/场景6/场景7/场景8,/场景9,/场景10'); // 测试获取产品 1 模块 0 起始场景 0 分支 1 当前场景 0 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[0], $branchIdList[0], $currentScene[1], $emptyMenu[0])) && p() && e('/,/场景1,/场景1/场景2,/场景3,/场景4,/场景5,/场景9,/场景10'); // 测试获取产品 1 模块 0 起始场景 0 分支 all 当前场景 6 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[0], $branchIdList[0], $currentScene[0], $emptyMenu[1])) && p() && e('/,/场景1,/场景1/场景2,/场景3,/场景4,/场景5,/场景6,/场景6/场景7,/场景6/场景7/场景8,/场景9,/场景10,空'); // 测试获取产品 1 模块 0 起始场景 0 分支 all 当前场景 0 有空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[0], $moduleIdList[1], $sceneIdList[1], $branchIdList[1], $currentScene[1], $emptyMenu[0])) && p() && e('/,/场景7,/场景7/场景8'); // 测试获取产品 1 模块 1 起始场景 6 分支 '0' 当前场景 6 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[0], $moduleIdList[1], $sceneIdList[1], $branchIdList[1], $currentScene[1], $emptyMenu[0])) && p() && e('/,/场景7,/场景7/场景8'); // 测试获取产品 1 模块 1 起始场景 6 分支 '0' 当前场景 6 有空值 的场景数组
|
||||
|
||||
r($testcase->getSceneMenuTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[0], $currentScene[0], $emptyMenu[0])) && p() && e('/,/场景11,/场景11/场景12,/场景11/场景12/场景13,/场景11/场景12/场景13/场景14,/场景11/场景15,/场景16,/场景16/场景17,/场景18,/场景18/场景19,/场景18/场景19/场景20'); // 测试获取产品 41 模块 0 起始场景 0 分支 all 当前场景 0 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[1], $moduleIdList[2], $sceneIdList[0], $branchIdList[0], $currentScene[0], $emptyMenu[0])) && p() && e('/,/场景16,/场景16/场景17,/场景18,/场景18/场景19,/场景18/场景19/场景20'); // 测试获取产品 41 模块 2 起始场景 0 分支 all 当前场景 0 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[1], $moduleIdList[0], $sceneIdList[2], $branchIdList[0], $currentScene[0], $emptyMenu[0])) && p() && e('/,/场景16,/场景16/场景17'); // 测试获取产品 41 模块 0 起始场景 6 分支 all 当前场景 0 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[2], $currentScene[0], $emptyMenu[0])) && p() && e('/,/分支1/场景16,/分支1/场景16/场景17,/分支1/场景18,/分支1/场景18/场景19,/分支1/场景18/场景19/场景20'); // 测试获取产品 41 模块 0 起始场景 0 分支 '0' 当前场景 0 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[2], $currentScene[0], $emptyMenu[0])) && p() && e('/,/分支1/场景16,/分支1/场景16/场景17,/分支1/场景18,/分支1/场景18/场景19,/分支1/场景18/场景19/场景20'); // 测试获取产品 41 模块 0 起始场景 0 分支 1 当前场景 0 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[0], $currentScene[2], $emptyMenu[0])) && p() && e('/,/场景11,/场景11/场景12,/场景11/场景12/场景13,/场景11/场景12/场景13/场景14,/场景11/场景15,/场景18,/场景18/场景19,/场景18/场景19/场景20'); // 测试获取产品 41 模块 0 起始场景 0 分支 all 当前场景 6 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[0], $currentScene[0], $emptyMenu[1])) && p() && e('/,/场景11,/场景11/场景12,/场景11/场景12/场景13,/场景11/场景12/场景13/场景14,/场景11/场景15,/场景16,/场景16/场景17,/场景18,/场景18/场景19,/场景18/场景19/场景20,空'); // 测试获取产品 41 模块 0 起始场景 0 分支 all 当前场景 0 有空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[1], $moduleIdList[2], $sceneIdList[2], $branchIdList[2], $currentScene[2], $emptyMenu[0])) && p() && e('/,/分支1/场景17'); // 测试获取产品 41 模块 2 起始场景 6 分支 '0' 当前场景 6 无空值 的场景数组
|
||||
r($testcase->getSceneMenuTest($productIdList[1], $moduleIdList[2], $sceneIdList[2], $branchIdList[2], $currentScene[2], $emptyMenu[0])) && p() && e('/,/分支1/场景17'); // 测试获取产品 41 模块 2 起始场景 6 分支 '0' 当前场景 6 有空值 的场景数组
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/testcase.class.php';
|
||||
|
||||
zdTable('scene')->config('modulescene')->gen('20');
|
||||
zdTable('user')->gen('1');
|
||||
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 testcaseModel->getScenesForMenu();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
$productIdList = array(0, 1, 2);
|
||||
$moduleIdList = array(0, 1821, 1825);
|
||||
$sceneIdList = array(0, 1, 6);
|
||||
$branchIdList = array('all', '', '0');
|
||||
$currentScene = 1;
|
||||
|
||||
$testcase = new testcaseTest();
|
||||
|
||||
r($testcase->getScenesForMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[0])) && p() && e('1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20'); // 测试获取产品 0 模块 0 起始场景 0 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[0], $branchIdList[0])) && p() && e('1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20'); // 测试获取产品 0 模块 0 起始场景 0 分支 all 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[0], $branchIdList[1])) && p() && e('1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20'); // 测试获取产品 0 模块 0 起始场景 0 分支 '' 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[0], $branchIdList[2])) && p() && e('1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20'); // 测试获取产品 0 模块 0 起始场景 0 分支 0 的场景
|
||||
|
||||
r($testcase->getScenesForMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[1])) && p() && e('1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20'); // 测试获取产品 0 模块 0 起始场景 1 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[1], $branchIdList[2])) && p() && e('1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20'); // 测试获取产品 0 模块 0 起始场景 1 分支 0 的场景
|
||||
|
||||
r($testcase->getScenesForMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[2])) && p() && e('1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20'); // 测试获取产品 0 模块 0 起始场景 6 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[2], $branchIdList[2])) && p() && e('1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20'); // 测试获取产品 0 模块 0 起始场景 6 分支 0 的场景
|
||||
|
||||
|
||||
r($testcase->getScenesForMenuTest($productIdList[1], $moduleIdList[0], $sceneIdList[0])) && p() && e('1,2,3,4'); // 测试获取产品 1 模块 0 起始场景 0 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[0])) && p() && e('1,2,3,4'); // 测试获取产品 1 模块 0 起始场景 0 分支 all 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[1])) && p() && e('1,2,3,4'); // 测试获取产品 1 模块 0 起始场景 0 分支 '' 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[2])) && p() && e('1,2,3,4'); // 测试获取产品 1 模块 0 起始场景 0 分支 0 的场景
|
||||
|
||||
r($testcase->getScenesForMenuTest($productIdList[1], $moduleIdList[0], $sceneIdList[1])) && p() && e('1,2,3,4'); // 测试获取产品 1 模块 0 起始场景 1 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[1], $moduleIdList[0], $sceneIdList[1], $branchIdList[2])) && p() && e('1,2,3,4'); // 测试获取产品 1 模块 0 起始场景 1 分支 0 的场景
|
||||
|
||||
r($testcase->getScenesForMenuTest($productIdList[1], $moduleIdList[1], $sceneIdList[1])) && p() && e('1'); // 测试获取产品 1 模块 1821 起始场景 1 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[1], $moduleIdList[1], $sceneIdList[1], $branchIdList[2])) && p() && e('1'); // 测试获取产品 1 模块 1821 起始场景 1 分支 0 的场景
|
||||
|
||||
|
||||
r($testcase->getScenesForMenuTest($productIdList[2], $moduleIdList[0], $sceneIdList[0])) && p() && e('5,6,7,8'); // 测试获取产品 2 模块 0 起始场景 0 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[2], $moduleIdList[0], $sceneIdList[0], $branchIdList[0])) && p() && e('5,6,7,8'); // 测试获取产品 2 模块 0 起始场景 0 分支 all 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[2], $moduleIdList[0], $sceneIdList[0], $branchIdList[1])) && p() && e('5,6,7,8'); // 测试获取产品 2 模块 0 起始场景 0 分支 '' 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[2], $moduleIdList[0], $sceneIdList[0], $branchIdList[2])) && p() && e('5,6,7,8'); // 测试获取产品 2 模块 0 起始场景 0 分支 0 的场景
|
||||
|
||||
r($testcase->getScenesForMenuTest($productIdList[2], $moduleIdList[0], $sceneIdList[1])) && p() && e('5,6,7,8'); // 测试获取产品 2 模块 0 起始场景 161 的场景
|
||||
r($testcase->getScenesForMenuTest($productIdList[2], $moduleIdList[0], $sceneIdList[1], $branchIdList[2])) && p() && e('5,6,7,8'); // 测试获取产品 2 模块 0 起始场景 161 分支 0 的场景
|
||||
|
||||
r($testcase->getScenesForMenuTest($productIdList[0], $moduleIdList[0], $sceneIdList[0], $branchIdList[2], $currentScene)) && p() && e('2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20'); // 测试获取产品 0 模块 0 起始场景 0 分支 0 的场景 排除 1
|
||||
r($testcase->getScenesForMenuTest($productIdList[1], $moduleIdList[0], $sceneIdList[0], $branchIdList[2], $currentScene)) && p() && e('2,3,4'); // 测试获取产品 1 模块 0 起始场景 0 分支 0 的场景 排除 1
|
||||
@@ -1374,21 +1374,22 @@ class testcaseTest
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试构建菜单查询。
|
||||
* Test build menu query.
|
||||
* 为构建场景菜单获取场景。
|
||||
* Get scenes for menu.
|
||||
*
|
||||
* @param int $rootID
|
||||
* @param int $productID
|
||||
* @param int $moduleID
|
||||
* @param int $startScene
|
||||
* @param string $branch
|
||||
* @param int $currentScene
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function buildMenuQueryTest(int $rootID, int $moduleID, int $startScene = 0, string $branch = 'all'): string
|
||||
public function getScenesForMenuTest(int $productID, int $moduleID, int $startScene = 0, string $branch = 'all', int $currentScene = 0): string
|
||||
{
|
||||
$query = $this->objectModel->buildMenuQuery($rootID, $moduleID, $startScene, $branch);
|
||||
$scenes = $this->objectModel->getScenesForMenu($productID, $moduleID, $startScene, $branch, $currentScene);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $query;
|
||||
return implode(',', array_keys($scenes));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1667,4 +1668,24 @@ class testcaseTest
|
||||
if(isset($scene['cases'])) $return .= ' cases: ' . implode(',', array_column($scene['cases'], 'id')) . '; ';
|
||||
return trim($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试获取场景菜单。
|
||||
* Test get scene menu.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $moduleID
|
||||
* @param int $startScene
|
||||
* @param int $branch
|
||||
* @param int $currentScene
|
||||
* @param bool $emptyMenu
|
||||
* @access public
|
||||
* @return array|string
|
||||
*/
|
||||
public function getSceneMenuTest(int $productID, int $moduleID, int $startScene = 0, int|string $branch = 0, int $currentScene = 0, bool $emptyMenu = false): array|string
|
||||
{
|
||||
$scenes = $this->objectModel->getSceneMenu($productID, $moduleID, $startScene, $branch, $currentScene, $emptyMenu);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return implode(',', $scenes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
title: table zt_scene
|
||||
desc: "用例"
|
||||
author: Mengyi Liu
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-1000
|
||||
- field: parent
|
||||
range: 0,1,0,0,0,0,6,7,0,0,0,11,12,13,11,0,16,0,18,19
|
||||
- field: title
|
||||
range: 1-1000
|
||||
prefix: 场景
|
||||
- field: product
|
||||
range: 1{10},41{10}
|
||||
- field: branch
|
||||
range: 0{15},1{5}
|
||||
- field: module
|
||||
range: 0{5},1{5},0{5},2{5}
|
||||
- field: grade
|
||||
range: 1,2,1{4},2,3,1{3},2,3,4,2,1,2,1,2,3
|
||||
- field: path
|
||||
fields:
|
||||
- field: path1
|
||||
range: 0{13},11,0{6}
|
||||
postfix: ","
|
||||
prefix: ","
|
||||
- field: path2
|
||||
range: 0{7},6,0{4},11,12,0{5},18
|
||||
postfix: ","
|
||||
- field: path3
|
||||
range: 0,1,0{4},6,7,0{3},11-13,11,0,16,0,18,19,
|
||||
postfix: ","
|
||||
- field: path4
|
||||
range: 1-20
|
||||
postfix: ","
|
||||
@@ -288,7 +288,7 @@ class testcaseZen extends testcase
|
||||
|
||||
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testcase->newScene;
|
||||
$this->view->modules = $this->tree->getOptionMenu($productID, 'case', 0, ($branch === 'all' || !isset($branches[$branch])) ? 0 : $branch);
|
||||
$this->view->scenes = $this->testcase->getSceneMenu($productID, $moduleID, 'case', 0, ($branch === 'all' || !isset($branches[$branch])) ? 0 : $branch);
|
||||
$this->view->scenes = $this->testcase->getSceneMenu($productID, $moduleID, 0, ($branch === 'all' || !isset($branches[$branch])) ? 0 : $branch);
|
||||
$this->view->moduleID = $moduleID ? (int)$moduleID : (int)$this->cookie->lastCaseModule;
|
||||
$this->view->parent = (int)$this->cookie->lastCaseScene;
|
||||
$this->view->product = $product;
|
||||
@@ -331,7 +331,7 @@ class testcaseZen extends testcase
|
||||
$modules = $this->tree->getOptionMenu($productID, 'case', 0, $branchID);
|
||||
if(!isset($modules[$moduleID])) $modules += $this->tree->getModulesName($moduleID);
|
||||
|
||||
$scenes = $this->testcase->getSceneMenu($productID, $moduleID, 'case', 0, $branchID, $oldScene->id);
|
||||
$scenes = $this->testcase->getSceneMenu($productID, $moduleID, 0, $branchID, $oldScene->id);
|
||||
if(!isset($scenes[$parentID])) $scenes += $this->testcase->getScenesName($parentID);
|
||||
|
||||
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testcase->editScene;
|
||||
@@ -387,7 +387,7 @@ class testcaseZen extends testcase
|
||||
$this->view->stories = $stories;
|
||||
$this->view->currentModuleID = $currentModuleID;
|
||||
$this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, 'case', 0, $branch === 'all' || !isset($branches[$branch]) ? 0 : $branch);
|
||||
$this->view->sceneOptionMenu = $this->testcase->getSceneMenu($productID, $moduleID, 'case', 0, $branch === 'all' || !isset($branches[$branch]) ? 0 : $branch);
|
||||
$this->view->sceneOptionMenu = $this->testcase->getSceneMenu($productID, $moduleID, 0, $branch === 'all' || !isset($branches[$branch]) ? 0 : $branch);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -568,7 +568,7 @@ class testcaseZen extends testcase
|
||||
$this->view->caseType = $caseType;
|
||||
$this->view->users = $this->user->getPairs('noletter');
|
||||
$this->view->modules = $this->tree->getOptionMenu($productID, $viewType = 'case', $startModuleID = 0, $branch == 'all' ? '0' : $branch);
|
||||
$this->view->iscenes = $this->testcase->getSceneMenu($productID, $moduleID, $viewType = 'case', $startSceneID = 0, 0);
|
||||
$this->view->iscenes = $this->testcase->getSceneMenu($productID, $moduleID, 0, 0);
|
||||
$this->view->suiteList = $this->loadModel('testsuite')->getSuites($productID);
|
||||
$this->view->modulePairs = $showModule ? $this->tree->getModulePairs($productID, 'case', $showModule) : array();
|
||||
$this->view->libraries = $this->loadModel('caselib')->getLibraries();
|
||||
@@ -886,7 +886,7 @@ class testcaseZen extends testcase
|
||||
*/
|
||||
protected function assignForEdit(int $productID, object $case, array $testtasks): void
|
||||
{
|
||||
$sceneOptionMenu = $this->testcase->getSceneMenu($productID, $case->module, $viewType = 'case', $startSceneID = 0, 0);
|
||||
$sceneOptionMenu = $this->testcase->getSceneMenu($productID, $case->module, 0, 0);
|
||||
if(!isset($sceneOptionMenu[$case->scene])) $sceneOptionMenu += $this->testcase->getScenesName($case->scene);
|
||||
|
||||
$forceNotReview = $this->testcase->forceNotReview();
|
||||
@@ -1067,7 +1067,7 @@ class testcaseZen extends testcase
|
||||
if(!isset($moduleScenesPairs[$case->module]))
|
||||
{
|
||||
$moduleScenesPairs[$case->module] = array();
|
||||
$moduleScenes = $this->testcase->getSceneMenu($productID, $case->module, 'case', 0, $branch === 'all' || !isset($branches[$branch]) ? 0 : $branch);
|
||||
$moduleScenes = $this->testcase->getSceneMenu($productID, $case->module, 0, $branch === 'all' || !isset($branches[$branch]) ? 0 : $branch);
|
||||
foreach($moduleScenes as $sceneID => $scene) $moduleScenesPairs[$case->module][] = array('text' => $scene, 'value' => $sceneID);
|
||||
}
|
||||
$scenePairs[$case->id][] = $moduleScenesPairs[$case->module];
|
||||
@@ -1265,7 +1265,7 @@ class testcaseZen extends testcase
|
||||
$this->view->showFields = $showFields;
|
||||
$this->view->story = $story;
|
||||
$this->view->storyPairs = $storyPairs;
|
||||
$this->view->sceneOptionMenu = $this->testcase->getSceneMenu($productID, $moduleID, 'case', 0, $branch === 'all' || !isset($branches[$branch]) ? 0 : $branch);
|
||||
$this->view->sceneOptionMenu = $this->testcase->getSceneMenu($productID, $moduleID, 0, $branch === 'all' || !isset($branches[$branch]) ? 0 : $branch);
|
||||
$this->view->currentModuleID = $moduleID;
|
||||
}
|
||||
|
||||
@@ -2330,7 +2330,7 @@ class testcaseZen extends testcase
|
||||
|
||||
$this->config->testcase->search['params']['product']['values'] = array('') + $productList;
|
||||
$this->config->testcase->search['params']['module']['values'] = $modules;
|
||||
$this->config->testcase->search['params']['scene']['values'] = $this->testcase->getSceneMenu($productID, $moduleID, $viewType = 'case', $startSceneID = 0, $branch, 0, true);
|
||||
$this->config->testcase->search['params']['scene']['values'] = $this->testcase->getSceneMenu($productID, $moduleID, 0, $branch, 0, true);
|
||||
$this->config->testcase->search['params']['lib']['values'] = $this->loadModel('caselib')->getLibraries();
|
||||
|
||||
if($this->session->currentProductType == 'normal')
|
||||
|
||||
Reference in New Issue
Block a user