* Add unit test of testcaseTao::fixScenePath.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/testcase.class.php';
|
||||
|
||||
zdTable('scene')->config('treescene')->gen(10);
|
||||
zdTable('user')->gen(1);
|
||||
|
||||
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();
|
||||
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 testcaseTao->fixScenePath();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
$testcase = new testcaseTest();
|
||||
|
||||
$sceneIdList = array(2, 3, 4);
|
||||
$pSceneIdList = array(1, 7);
|
||||
|
||||
r($testcase->fixScenePathTest($sceneIdList[0], $pSceneIdList[0])) && p() && e('id:2, parent:1, path:,1,2,, grade:2'); // 测试将场景 2 移动到场景 1 下面
|
||||
r($testcase->fixScenePathTest($sceneIdList[0], $pSceneIdList[1])) && p() && e('id:2, parent:7, path:,6,7,2,, grade:3'); // 测试将场景 2 移动到场景 7 下面
|
||||
r($testcase->fixScenePathTest($sceneIdList[1], $pSceneIdList[0])) && p() && e('id:3, parent:1, path:,1,3,, grade:2'); // 测试将场景 3 移动到场景 1 下面
|
||||
r($testcase->fixScenePathTest($sceneIdList[1], $pSceneIdList[1])) && p() && e('id:3, parent:7, path:,6,7,3,, grade:3'); // 测试将场景 3 移动到场景 7 下面
|
||||
r($testcase->fixScenePathTest($sceneIdList[2], $pSceneIdList[0])) && p() && e('id:4, parent:1, path:,1,4,, grade:2'); // 测试将场景 4 移动到场景 1 下面
|
||||
r($testcase->fixScenePathTest($sceneIdList[2], $pSceneIdList[1])) && p() && e('id:4, parent:7, path:,6,7,4,, grade:3'); // 测试将场景 4 移动到场景 7 下面
|
||||
@@ -1764,4 +1764,24 @@ class testcaseTest
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试调整场景的路径。。
|
||||
* Test fix the scene path.
|
||||
*
|
||||
* @param int $sceneID
|
||||
* @access public
|
||||
* @return string|array
|
||||
*/
|
||||
public function fixScenePathTest($sceneID, $pSceneID): string|array
|
||||
{
|
||||
$pScene = array('id' => $pSceneID);
|
||||
$this->objectModel->fixScenePath($sceneID, $pScene);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
$scene = $this->objectModel->getSceneByID($sceneID);
|
||||
$return = "id:{$scene->id}, parent:{$scene->parent}, path:{$scene->path}, grade:{$scene->grade}";
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,18 +11,20 @@ fields:
|
||||
range: 1{10},41{10}
|
||||
- field: branch
|
||||
range: 0{15},1{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: 1-11,11{4},16{2},18,18{3}
|
||||
prefix: ","
|
||||
range: 0{13},11,0{6}
|
||||
postfix: ","
|
||||
prefix: ","
|
||||
- field: path2
|
||||
range: 0{11},12{3},15,0,17,0,19{2}
|
||||
range: 0{7},6,0{4},11,12,0{5},18
|
||||
postfix: ","
|
||||
- field: path3
|
||||
range: 0{12},13{2},0{5},20
|
||||
range: 0,1,0{4},6,7,0{3},11-13,11,0,16,0,18,19,
|
||||
postfix: ","
|
||||
- field: path5
|
||||
range: 0{13},14,0{4}
|
||||
- field: path4
|
||||
range: 1-20
|
||||
postfix: ","
|
||||
|
||||
Reference in New Issue
Block a user