+ [misc] Add unit tests for treeZen::setRoot() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-19 11:06:07 +08:00
co-authored by Claude
parent 368229ba7a
commit 528161929d
2 changed files with 65 additions and 0 deletions
@@ -0,0 +1,28 @@
<?php
declare(strict_types = 1);
class treeTest
{
public function __construct()
{
$this->objectZen = initReference('tree');
}
/**
* Test setRoot method.
*
* @param int $rootID
* @param string $viewType
* @param string $branch
* @access public
* @return mixed
*/
public function setRootTest(int $rootID = 0, string $viewType = '', string $branch = '')
{
$method = $this->objectZen->getMethod('setRoot');
$method->setAccessible(true);
$result = $method->invokeArgs($this->objectZen->newInstance(), array($rootID, $viewType, $branch));
if(dao::isError()) return dao::getError();
return $result;
}
}
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env php
<?php
/**
title=测试 treeZen::setRoot();
timeout=0
cid=0
- 执行treeTest模块的setRootTest方法,参数是0, 'line', ''
- 属性id @0
- 属性rootType @line
- 执行treeTest模块的setRootTest方法,参数是0, 'host', ''
- 属性id @0
- 属性rootType @line
- 执行treeTest模块的setRootTest方法,参数是0, 'datasource', ''
- 属性id @0
- 属性rootType @line
- 执行treeTest模块的setRootTest方法,参数是1, 'bug', '' 属性rootType @product
- 执行treeTest模块的setRootTest方法,参数是1, 'story', '' 属性rootType @product
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/treezen.unittest.class.php';
zenData('product')->loadYaml('product', false, 2)->gen(5);
su('admin');
$treeTest = new treeTest();
r($treeTest->setRootTest(0, 'line', '')) && p('id,rootType') && e('0,line');
r($treeTest->setRootTest(0, 'host', '')) && p('id,rootType') && e('0,line');
r($treeTest->setRootTest(0, 'datasource', '')) && p('id,rootType') && e('0,line');
r($treeTest->setRootTest(1, 'bug', '')) && p('rootType') && e('product');
r($treeTest->setRootTest(1, 'story', '')) && p('rootType') && e('product');