Keep the public site readable after import (nbsp, highlighter, wrapping code, compact pager) and finish the admin extras already in this tree: sticky levels, preview, page cache, and live llms.txt. Co-authored-by: Cursor <cursoragent@cursor.com>
73 lines
2.1 KiB
PHP
73 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Filament\Resources\Posts\Pages\EditPost;
|
|
use App\Filament\Resources\Posts\RelationManagers\CommentsRelationManager;
|
|
use App\Models\Post;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\File;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
class FilamentV5CompatTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_no_legacy_filament_table_action_imports(): void
|
|
{
|
|
$legacy = [];
|
|
|
|
foreach ([app_path(), base_path('plugins')] as $root) {
|
|
foreach (File::allFiles($root) as $file) {
|
|
if ($file->getExtension() !== 'php') {
|
|
continue;
|
|
}
|
|
|
|
$path = $file->getPathname();
|
|
if (str_contains(File::get($path), 'Filament\\Tables\\Actions\\')) {
|
|
$legacy[] = $path;
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->assertSame(
|
|
[],
|
|
$legacy,
|
|
'Filament v5 table actions must use Filament\\Actions, not Filament\\Tables\\Actions'
|
|
);
|
|
}
|
|
|
|
public function test_edit_post_boots_comments_relation_manager(): void
|
|
{
|
|
$this->seed();
|
|
|
|
$admin = User::query()->where('email', 'admin@laralog.test')->firstOrFail();
|
|
$this->actingAs($admin);
|
|
|
|
$post = Post::create([
|
|
'user_id' => $admin->id,
|
|
'title' => '评论关系测试',
|
|
'slug' => 'comment-relation-test',
|
|
'content' => '内容',
|
|
'content_format' => 'markdown',
|
|
'status' => 'published',
|
|
'published_at' => now(),
|
|
]);
|
|
|
|
$this->get('/admin/posts/'.$post->id.'/edit')->assertOk();
|
|
|
|
Livewire::test(EditPost::class, ['record' => $post->getRouteKey()])
|
|
->assertSuccessful();
|
|
|
|
// The comments table only instantiates here. A GET of the edit page does not catch a bad Action import.
|
|
Livewire::test(CommentsRelationManager::class, [
|
|
'ownerRecord' => $post,
|
|
'pageClass' => EditPost::class,
|
|
])->assertSuccessful();
|
|
}
|
|
}
|