M7: 全量测试(25 用例)+ README + 部署文档(nginx/systemd/cron)+ theme:publish 命令

This commit is contained in:
ak
2026-08-11 18:48:16 +08:00
parent 933736cfdd
commit fb9175402a
12 changed files with 802 additions and 65 deletions
+62
View File
@@ -0,0 +1,62 @@
<?php
namespace Tests\Feature;
use App\Models\Setting;
use App\Models\Post;
use App\Models\Category;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ThemeTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
$this->seed();
$user = User::create(['name' => '作者', 'email' => 't@test.com', 'password' => bcrypt('x')]);
$category = Category::create(['name' => '分类', 'slug' => 'cat']);
Post::create([
'user_id' => $user->id,
'category_id' => $category->id,
'title' => '主题测试',
'slug' => 'theme-test',
'content' => '内容',
'content_format' => 'markdown',
'status' => 'published',
'published_at' => now(),
]);
}
public function test_sablog_theme_renders_classic_layout(): void
{
app(\App\Blog\Support\ThemeManager::class)->activate('sablog');
$this->get('/')->assertOk()->assertSee('outmain');
$this->get('/posts/theme-test')->assertOk()->assertSee('outmain');
}
public function test_modern_theme_renders_modern_layout(): void
{
app(\App\Blog\Support\ThemeManager::class)->activate('modern');
$this->get('/')->assertOk()->assertSee('m-header');
$this->get('/posts/theme-test')->assertOk()->assertSee('m-header');
}
public function test_theme_assets_are_served(): void
{
$this->get('/themes/sablog/assets/style.css')->assertOk()->assertHeader('Content-Type', 'text/css; charset=utf-8');
$this->get('/themes/modern/assets/style.css')->assertOk();
$this->get('/themes/nonexistent/assets/style.css')->assertNotFound();
}
public function test_unknown_theme_falls_back_to_default(): void
{
Setting::set('active_theme', 'does-not-exist');
$this->get('/')->assertOk();
}
}