mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-09 01:35:35 +08:00
rename test folder
This commit is contained in:
50
tests/ZM/Utils/Manager/ModuleManagerTest.php
Normal file
50
tests/ZM/Utils/Manager/ModuleManagerTest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace ZM\Utils\Manager;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ZM\Config\ZMConfig;
|
||||
use ZM\Console\Console;
|
||||
use ZM\Utils\DataProvider;
|
||||
|
||||
class ModuleManagerTest extends TestCase
|
||||
{
|
||||
public function setUp(): void {
|
||||
file_put_contents(DataProvider::getSourceRootDir()."/src/Module/zm.json", json_encode([
|
||||
"name" => "示例模块2"
|
||||
]));
|
||||
|
||||
ZMConfig::setDirectory(DataProvider::getSourceRootDir() . '/config');
|
||||
ZMConfig::setEnv($args["env"] ?? "");
|
||||
if (ZMConfig::get("global") === false) {
|
||||
die (zm_internal_errcode("E00007") . "Global config load failed: " . ZMConfig::$last_error . "\nPlease init first!\nSee: https://github.com/zhamao-robot/zhamao-framework/issues/37\n");
|
||||
}
|
||||
|
||||
//定义常量
|
||||
include_once DataProvider::getFrameworkRootDir()."/src/ZM/global_defines.php";
|
||||
|
||||
Console::init(
|
||||
ZMConfig::get("global", "info_level") ?? 2,
|
||||
null,
|
||||
$args["log-theme"] ?? "default",
|
||||
($o = ZMConfig::get("console_color")) === false ? [] : $o
|
||||
);
|
||||
|
||||
$timezone = ZMConfig::get("global", "timezone") ?? "Asia/Shanghai";
|
||||
date_default_timezone_set($timezone);
|
||||
}
|
||||
|
||||
public function tearDown(): void {
|
||||
unlink(DataProvider::getSourceRootDir()."/src/Module/zm.json");
|
||||
}
|
||||
|
||||
public function testGetConfiguredModules() {
|
||||
zm_dump(ModuleManager::getConfiguredModules());
|
||||
$this->assertArrayHasKey("示例模块", ModuleManager::getConfiguredModules());
|
||||
}
|
||||
|
||||
public function testPackModule() {
|
||||
$list = ModuleManager::getConfiguredModules();
|
||||
$this->assertTrue(ModuleManager::packModule(current($list)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user