mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-08-30 12:45:32 +08:00
feat(test): 引入测试规则文档与参数化测试库初始化脚本
对齐 wkbox 衍生项目的测试规则体系,剥离业务特定内容后移植到框架:
- 规则 .agents/rules/ulthon-testing.md(设计哲学/决策树/4层模型/安全规范/fixture原则)
- 技能 .agents/skills/ulthon-testing(运行/编写/模板/决策/回归验证)
- 参数化建库脚本 tests/setup_test_db.{php,ps1,sh} + README
- AGENTS.md 索引补充
与 wkbox 差异:测试库参数化(复用 .env 连接,database=env+'_test'),不硬编码 Docker;删去 canBind Oracle 业务约束与具体 fixture 工厂,业务工厂由衍生项目自行实现。
This commit is contained in:
46
tests/setup_test_db.ps1
Normal file
46
tests/setup_test_db.ps1
Normal file
@@ -0,0 +1,46 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Test database setup (Windows / PowerShell wrapper).
|
||||
|
||||
.DESCRIPTION
|
||||
Calls the PHP runner tests/setup_test_db.php, which in a single process:
|
||||
1. reads connection params from .env (hostname/hostport/username/password/
|
||||
charset/prefix/database)
|
||||
2. derives the test DB name as {env.database} + '_test'
|
||||
(e.g. ulthon_admin -> ulthon_admin_test)
|
||||
3. CREATE DATABASE IF NOT EXISTS on the same MySQL instance (no Docker)
|
||||
4. config-level override connections.main -> test DB
|
||||
5. php think migrate:run -> system/framework tables (database/migrations/)
|
||||
6. php think scheme:sync -> business tables (app/admin/scheme/)
|
||||
7. php think seed:run -> reference data (database/seeds/)
|
||||
8. queries information_schema to verify the tables landed in the test DB
|
||||
|
||||
Fully parameterized: no hardcoded host/port/credentials. The MySQL instance
|
||||
is whatever .env points at (typically a single local MySQL).
|
||||
|
||||
.NOTES
|
||||
ASCII-only on purpose: PowerShell 5.1 mis-decodes BOM-less UTF-8 CJK.
|
||||
#>
|
||||
|
||||
# Runner lives next to this script.
|
||||
$Runner = Join-Path $PSScriptRoot 'setup_test_db.php'
|
||||
|
||||
# 1. Ensure php is on PATH.
|
||||
$phpCmd = Get-Command php -ErrorAction SilentlyContinue
|
||||
if (-not $phpCmd) {
|
||||
Write-Host "[ERROR] 'php' not found on PATH. Install PHP 8+ and add it to PATH." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 2. Run the PHP runner.
|
||||
Write-Host "==== Running setup_test_db.php ====" -ForegroundColor Cyan
|
||||
& php $Runner
|
||||
$code = $LASTEXITCODE
|
||||
|
||||
Write-Host ""
|
||||
if ($code -eq 0) {
|
||||
Write-Host "==== Done. PHP exit code = $code ====" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "==== Done. PHP exit code = $code ====" -ForegroundColor Red
|
||||
}
|
||||
exit $code
|
||||
Reference in New Issue
Block a user