diff --git a/module/admin/test/lib/admin.unittest.class.php b/module/admin/test/lib/admin.unittest.class.php index 1344289bf1..8601e47d2a 100644 --- a/module/admin/test/lib/admin.unittest.class.php +++ b/module/admin/test/lib/admin.unittest.class.php @@ -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; + } } diff --git a/module/admin/test/zen/syncextensions.php b/module/admin/test/zen/syncextensions.php new file mode 100755 index 0000000000..93d2af28c7 --- /dev/null +++ b/module/admin/test/zen/syncextensions.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +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'); \ No newline at end of file