mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2026-06-07 12:38:11 +08:00
将 v6 中直接放在本地 app 的后台与微信能力迁移为 v8 插件组件,并把运行时基础能力沉淀到独立插件包。 主要内容: - 新增 think-library、system、worker、static、install 等基础插件包。 - 新增 account、payment、wechat-client、wechat-service、wemall、wuma 等业务插件包。 - 移除 v6 的 app/admin 与 app/wechat 本地应用实现,改由插件分发接管。 - 将 Helper 能力彻底并入 System,统一为 plugin\system\helper\* 命名空间。 - 同步插件迁移发布清单与根 route 占位,保证安装发布流程可复现。
200 lines
9.2 KiB
PHP
200 lines
9.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
/**
|
|
* +----------------------------------------------------------------------
|
|
* | ThinkAdmin Plugin for ThinkAdminDeveloper
|
|
* +----------------------------------------------------------------------
|
|
* | Copyright (c) 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
|
* +----------------------------------------------------------------------
|
|
* | Official Website: https://thinkadmin.top
|
|
* +----------------------------------------------------------------------
|
|
* | Licensed: https://mit-license.org
|
|
* | Disclaimer: https://thinkadmin.top/disclaimer
|
|
* | Vip Rights: https://thinkadmin.top/vip-introduce
|
|
* +----------------------------------------------------------------------
|
|
* | Gitee Repository: https://gitee.com/zoujingli/ThinkAdmin
|
|
* | Github Repository: https://github.com/zoujingli/ThinkAdmin
|
|
* +----------------------------------------------------------------------
|
|
*/
|
|
|
|
namespace think\admin\tests;
|
|
|
|
use plugin\system\controller\Config as ConfigController;
|
|
use plugin\system\service\LangService;
|
|
use plugin\system\storage\StorageConfig;
|
|
use plugin\system\service\SystemContext as PluginSystemContext;
|
|
use think\admin\contract\SystemContextInterface;
|
|
use think\admin\runtime\RequestContext;
|
|
use think\admin\tests\Support\SqliteIntegrationTestCase;
|
|
use think\Container;
|
|
use think\exception\HttpResponseException;
|
|
use think\Request;
|
|
|
|
/**
|
|
* @internal
|
|
* @coversNothing
|
|
*/
|
|
class ConfigPageRenderTest extends SqliteIntegrationTestCase
|
|
{
|
|
public function testIndexRendersDashboardWithoutPluginCards(): void
|
|
{
|
|
$this->bindAdminUser();
|
|
|
|
$html = $this->callPageHtml('index');
|
|
|
|
$this->assertStringContainsString('统一管理运行模式、存储中心与系统基础参数', $html);
|
|
$this->assertStringContainsString('站点名称', $html);
|
|
$this->assertStringContainsString('插件中心', $html);
|
|
$this->assertStringContainsString('菜单入口策略', $html);
|
|
$this->assertStringContainsString('page-builder-schema', $html);
|
|
$this->assertStringContainsString('系统参数配置', $html);
|
|
$this->assertStringNotContainsString('插件应用', $html);
|
|
$this->assertStringNotContainsString('插件标识', $html);
|
|
}
|
|
|
|
public function testSystemRendersGroupedConfigurationSections(): void
|
|
{
|
|
$this->bindAdminUser();
|
|
sysdata('system.security', ['jwt_secret' => '1234567890abcdef1234567890abcdef']);
|
|
|
|
$html = $this->callPageHtml('system');
|
|
|
|
$this->assertStringContainsString('系统参数设置', $html);
|
|
$this->assertStringContainsString('保存修改', $html);
|
|
$this->assertStringContainsString('取消修改', $html);
|
|
$this->assertStringContainsString('class="system-config-form layui-form"', $html);
|
|
$this->assertStringContainsString('data-builder-scope="page"', $html);
|
|
$this->assertStringContainsString('站点品牌信息', $html);
|
|
$this->assertStringContainsString('data-target-submit', $html);
|
|
$this->assertStringContainsString('data-target-backup', $html);
|
|
$this->assertStringContainsString('data-open-site-theme', $html);
|
|
$this->assertStringContainsString("'760px'", $html);
|
|
$this->assertStringContainsString('form-builder-schema', $html);
|
|
$this->assertStringContainsString('运行参数', $html);
|
|
$this->assertStringContainsString('id="RefreshJwtKey"', $html);
|
|
$this->assertStringContainsString('type="password"', $html);
|
|
$this->assertStringContainsString('name="site[login_entry]"', $html);
|
|
$this->assertStringContainsString('data-field="site[browser_icon]"', $html);
|
|
$this->assertStringContainsString('name="site[host]"', $html);
|
|
$this->assertStringContainsString('站点基础域名', $html);
|
|
$this->assertStringNotContainsString('1234567890abcdef1234567890abcdef', $html);
|
|
$this->assertStringNotContainsString('统一管理登录入口、品牌信息与安全配置', $html);
|
|
}
|
|
|
|
public function testStorageRendersBuilderDashboard(): void
|
|
{
|
|
$this->bindAdminUser();
|
|
|
|
$html = $this->callPageHtml('storage');
|
|
|
|
$this->assertStringContainsString('统一管理文件上传、命名策略与外链输出', $html);
|
|
$this->assertStringContainsString('存储引擎', $html);
|
|
$this->assertStringContainsString('page-builder-schema', $html);
|
|
$this->assertStringContainsString('当前默认驱动', $html);
|
|
}
|
|
|
|
public function testStorageDriverFormRendersWithBuilder(): void
|
|
{
|
|
$this->bindAdminUser();
|
|
StorageConfig::save([
|
|
'default_driver' => 'local',
|
|
'naming_rule' => 'xmd5',
|
|
'link_mode' => 'none',
|
|
'allowed_extensions' => ['png', 'jpg'],
|
|
'drivers' => [
|
|
'local' => ['protocol' => 'follow', 'domain' => ''],
|
|
'alist' => ['protocol' => 'http', 'domain' => 'storage.example.com', 'path' => '/uploads', 'username' => 'root', 'password' => 'alist-secret'],
|
|
'qiniu' => ['protocol' => 'https', 'region' => 'z0', 'bucket' => 'demo', 'domain' => 'cdn.example.com', 'access_key' => 'ak-demo', 'secret_key' => 'sk-demo'],
|
|
'upyun' => ['protocol' => 'https', 'bucket' => 'demo', 'domain' => 'up.example.com', 'username' => 'operator', 'password' => 'up-secret'],
|
|
'txcos' => ['protocol' => 'https', 'region' => 'ap-shanghai', 'bucket' => 'demo', 'domain' => 'cos.example.com', 'access_key' => 'sid-demo', 'secret_key' => 'skey-demo'],
|
|
'alioss' => ['protocol' => 'https', 'region' => 'oss-cn-hangzhou', 'bucket' => 'demo', 'domain' => 'oss.example.com', 'access_key' => 'oss-ak', 'secret_key' => 'oss-sk'],
|
|
],
|
|
]);
|
|
|
|
$html = $this->callPageHtml('storage', ['type' => 'local']);
|
|
|
|
$this->assertStringContainsString('本地服务器存储 存储配置', $html);
|
|
$this->assertStringContainsString('返回存储中心', $html);
|
|
$this->assertStringContainsString('全局上传策略', $html);
|
|
$this->assertStringContainsString('本地服务器存储 驱动参数', $html);
|
|
$this->assertStringContainsString('form-builder-schema', $html);
|
|
$this->assertStringContainsString('data-builder-preset="dialog-form"', $html);
|
|
$this->assertStringContainsString('name="storage[default_driver]" value="local"', $html);
|
|
$this->assertStringNotContainsString('alist-secret', $html);
|
|
$this->assertStringNotContainsString('ak-demo', $html);
|
|
$this->assertStringNotContainsString('sk-demo', $html);
|
|
$this->assertStringNotContainsString('data-builder-preset="page-form"', $html);
|
|
$this->assertStringNotContainsString('统一维护上传策略与驱动参数', $html);
|
|
}
|
|
|
|
public function testSystemRendersEnglishTextsWhenLangSetIsEnUs(): void
|
|
{
|
|
$this->bindAdminUser();
|
|
sysdata('system.security', ['jwt_secret' => '1234567890abcdef1234567890abcdef']);
|
|
$this->switchSystemLang('en-us');
|
|
|
|
$html = $this->callPageHtml('system');
|
|
|
|
$this->assertStringContainsString('System Parameter Settings', $html);
|
|
$this->assertStringContainsString('Save Changes', $html);
|
|
$this->assertStringContainsString('Cancel Modification', $html);
|
|
$this->assertStringContainsString('Site Branding', $html);
|
|
$this->assertStringContainsString('Runtime Settings', $html);
|
|
$this->assertStringContainsString('Login Entry', $html);
|
|
$this->assertStringContainsString('Site Base URL', $html);
|
|
$this->assertStringContainsString('Site Name', $html);
|
|
$this->assertStringContainsString('Choose Backend Default Theme', $html);
|
|
$this->assertStringNotContainsString('站点品牌信息', $html);
|
|
}
|
|
|
|
protected function defineSchema(): void
|
|
{
|
|
$this->createSystemDataTable();
|
|
}
|
|
|
|
protected function afterSchemaCreated(): void
|
|
{
|
|
$context = new PluginSystemContext();
|
|
Container::getInstance()->instance(SystemContextInterface::class, $context);
|
|
$this->app->instance(SystemContextInterface::class, $context);
|
|
$this->configureView([
|
|
'view_path' => TEST_PROJECT_ROOT . '/plugin/think-plugs-system/src/view' . DIRECTORY_SEPARATOR,
|
|
]);
|
|
}
|
|
|
|
private function callPageHtml(string $action, array $query = []): string
|
|
{
|
|
$request = (new Request())
|
|
->setMethod('GET')
|
|
->setController('config')
|
|
->setAction($action)
|
|
->withGet($query);
|
|
|
|
$this->app->instance('request', $request);
|
|
|
|
try {
|
|
$controller = new ConfigController($this->app);
|
|
$controller->{$action}();
|
|
self::fail("Expected ConfigController::{$action} to throw HttpResponseException.");
|
|
} catch (HttpResponseException $exception) {
|
|
return $exception->getResponse()->getContent();
|
|
}
|
|
}
|
|
|
|
private function bindAdminUser(): void
|
|
{
|
|
RequestContext::instance()->setAuth([
|
|
'id' => 9101,
|
|
'username' => 'admin',
|
|
'password' => $this->hashSystemPassword('changed-password'),
|
|
], '', true);
|
|
}
|
|
|
|
private function switchSystemLang(string $langSet): void
|
|
{
|
|
$this->app->lang->switchLangSet($langSet);
|
|
LangService::load($this->app, $langSet);
|
|
}
|
|
}
|