+ [misc] Add unit tests for adminZen::syncExtensions() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,16 @@ class adminTest
|
||||
global $tester;
|
||||
$this->objectModel = $tester->loadModel('admin');
|
||||
$this->user = $tester->loadModel('user');
|
||||
|
||||
// 加载admin控制器基类
|
||||
if(!class_exists('admin'))
|
||||
{
|
||||
include dirname(__FILE__, 3) . '/control.php';
|
||||
}
|
||||
|
||||
// 包含zen文件并实例化
|
||||
require_once dirname(__FILE__, 3) . '/zen.php';
|
||||
$this->objectZen = new adminZen();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,4 +266,24 @@ class adminTest
|
||||
// 对于非空参数,返回1表示执行成功
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test syncExtensions method.
|
||||
*
|
||||
* @param string $type
|
||||
* @param int $limit
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function syncExtensionsTest(string $type = 'plugin', int $limit = 5)
|
||||
{
|
||||
$reflection = new ReflectionClass($this->objectZen);
|
||||
$method = $reflection->getMethod('syncExtensions');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($this->objectZen, $type, $limit);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 adminZen::syncExtensions();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行adminTest模块的syncExtensionsTest方法,参数是'plugin', 5 @1
|
||||
- 执行adminTest模块的syncExtensionsTest方法,参数是'patch', 5 @1
|
||||
- 执行adminTest模块的syncExtensionsTest方法,参数是'plugin', 10 @1
|
||||
- 执行adminTest模块的syncExtensionsTest方法,参数是'patch', 1 @1
|
||||
- 执行adminTest模块的syncExtensionsTest方法,参数是'plugin', 0 @1
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/admin.unittest.class.php';
|
||||
|
||||
su('admin');
|
||||
|
||||
$adminTest = new adminTest();
|
||||
|
||||
r($adminTest->syncExtensionsTest('plugin', 5)) && p() && e('1');
|
||||
r($adminTest->syncExtensionsTest('patch', 5)) && p() && e('1');
|
||||
r($adminTest->syncExtensionsTest('plugin', 10)) && p() && e('1');
|
||||
r($adminTest->syncExtensionsTest('patch', 1)) && p() && e('1');
|
||||
r($adminTest->syncExtensionsTest('plugin', 0)) && p() && e('1');
|
||||
Reference in New Issue
Block a user