+ [misc] Add unit tests for adminZen::getZentaoData() method

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-11-12 08:25:29 +08:00
co-authored by Claude
parent 4a8f822bd6
commit 262ef3ed45
2 changed files with 60 additions and 0 deletions
+13
View File
@@ -35,4 +35,17 @@ class adminZenTest extends baseTest
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test getZentaoData method.
*
* @access public
* @return mixed
*/
public function getZentaoDataTest()
{
$result = $this->invokeArgs('getZentaoData', []);
if(dao::isError()) return dao::getError();
return $result;
}
}
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env php
<?php
/**
title=测试 adminZen::getZentaoData();
timeout=0
cid=0
- 执行$methodExists @1
- 执行$hasDataProperty @1
- 执行$hasPluginsProperty @1
- 执行$hasAllProperties @1
- 执行$hasDataIsBoolean @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/zen.class.php';
su('admin');
global $config;
$adminTest = new adminZenTest();
// 步骤1:验证getZentaoData方法存在且可访问
$methodExists = method_exists($adminTest, 'getZentaoDataTest') ? 1 : 0;
r($methodExists) && p() && e(1);
// 步骤2:无zentaoWebsite配置时返回对象包含hasData属性
unset($config->zentaoWebsite);
$result = $adminTest->getZentaoDataTest();
$hasDataProperty = isset($result->hasData) ? 1 : 0;
r($hasDataProperty) && p() && e(1);
// 步骤3:无zentaoWebsite配置时返回对象包含plugins属性
$hasPluginsProperty = isset($result->plugins) && is_array($result->plugins) ? 1 : 0;
r($hasPluginsProperty) && p() && e(1);
// 步骤4:返回对象包含dynamics、classes、patches属性
$hasAllProperties = (isset($result->dynamics) && isset($result->classes) && isset($result->patches)) ? 1 : 0;
r($hasAllProperties) && p() && e(1);
// 步骤5:验证hasData属性值为布尔类型
$hasDataIsBoolean = is_bool($result->hasData) ? 1 : 0;
r($hasDataIsBoolean) && p() && e(1);