* Update test case for program settreepath.

This commit is contained in:
caoyanyi
2023-01-05 14:07:45 +08:00
parent 592aeee6cd
commit 4ecf205024
3 changed files with 37 additions and 14 deletions
+15
View File
@@ -134,4 +134,19 @@ class programTest
return $budget;
}
/**
* Set tree path.
*
* @param int $programID
* @access public
* @return void
*/
public function setTreePathTest($programID)
{
$this->program->setTreePath($programID);
$program = $this->program->getByID($programID);
return $program;
}
}
+4 -4
View File
@@ -257,7 +257,7 @@ class yaml
* @access public
* @return void
*/
public function gen($rows, $version = '')
public function gen($rows, $version = '1.0')
{
$runFileDir = dirname(getcwd() . DS . $_SERVER['SCRIPT_FILENAME']);
$runFileName = str_replace(strrchr($_SERVER['SCRIPT_FILENAME'], "."), "", $_SERVER['SCRIPT_FILENAME']);
@@ -268,9 +268,9 @@ class yaml
$yamlDataArr = array();
$yamlDataArr['title'] = "zt_{$this->tableName}";
$yamlDataArr['author'] = "auto_{$runFileName}";
$version ? $yamlDataArr['version'] = $version : $yamlDataArr['version'] = '1.0';
$yamlDataArr['title'] = "zt_{$this->tableName}";
$yamlDataArr['author'] = "auto_{$runFileName}";
$yamlDataArr['version'] = $version;
if(empty($this->fields->fieldArr))
{
+18 -10
View File
@@ -1,26 +1,34 @@
#!/usr/bin/env php
<?php
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/program.class.php';
su('admin');
$program = zdTable('project');
$program->id->range('1,10');
$program->name->range('项目集1');
$program->type->range('program');
$program->parent->range('[],[1]');
$program->path->range('1,10')->prefix(',')->postfix(',');
$program->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD');
$program->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD');
$program->gen(2);
/**
title=测试 programModel::setTreePath();
cid=1
pid=1
设置之前的项目集的path >> ,2,12,
设置之后的项目集的path >> ,2,12,
设置之前的项目集的path >> ,10,
设置之后的项目集的path >> ,1,10,
*/
global $tester;
$tester->loadModel('program');
$programTester = new programTest();
$before = $tester->program->getById(12);
$tester->program->setTreePath(12);
$after = $tester->program->getById(12);
$before = $programTester->getByIDTest(10);
$after = $programTester->setTreePathTest(10);
r($before) && p('path') && e(',2,12,'); // 设置之前的项目集的path
r($after) && p('path') && e(',2,12,'); // 设置之后的项目集的path
$db->restoreDB();
r($before) && p('path') && e(',10,'); // 设置之前的项目集的path
r($after) && p('path') && e(',1,10,'); // 设置之后的项目集的path