用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ForceInjection/domain-driven-design-skills --skill filament-testing命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Conduct deep academic research for philosophy, neuroscience, cognitive science, and theoretical computer science (computability, complexity, AI theory, logic). Use when user asks to: research academic topics, find scholarly papers, conduct literature reviews, analyze citations, synthesize research findings, explore philosophical arguments, investigate consciousness/cognition, study computability/decidability/Turing machines, or analyze academic debates. Triggers on: 'research papers', 'literature review', 'academic sources', 'scholarly articles', 'philosophy of mind', 'computability theory', 'neuroscience studies', 'find papers on', 'what does the research say'.
Create clear action plans with steps, success criteria, and risk awareness. Use before implementing features, making changes, starting projects, or anytime you need a roadmap to success. Triggers on "plan this", "how should we approach", "what's the strategy", "steps to complete", or when facing complex multi-step work.
Add keyboard navigation to a feature using CommandRegistryService. Use when implementing keyboard shortcuts, vim-style navigation, or hotkeys for a page or component.
基于 SOC 职业分类
正在显示 SKILL.md
| name | filament-testing |
| description | Generate Pest tests for FilamentPHP v4 resources, forms, tables, and authorization |
This skill generates comprehensive Pest tests for FilamentPHP v4 components following official testing documentation patterns.
CRITICAL: Before generating tests, read:
/home/mwguerra/projects/mwguerra/claude-code-plugins/filament-specialist/skills/filament-docs/references/general/10-testing/<?php
declare(strict_types=1);
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
protected function setUp(): void
{
parent::setUp();
// Login as admin for Filament tests
$this->actingAs(\App\Models\User::factory()->create([
'is_admin' => true,
]));
}
}
// tests/Pest.php
uses(Tests\TestCase::class)
->in('Feature');
uses(Illuminate\Foundation\Testing\RefreshDatabase::class)
->in('Feature');
<?php
declare(strict_types=1);
use App\Filament\Resources\PostResource;
use App\Filament\Resources\PostResource\Pages\ListPosts;
use App\Models\Post;
use App\Models\User;
use Filament\Actions\DeleteAction;
use Filament\Tables\Actions\DeleteBulkAction;
use function Pest\Livewire\livewire;
beforeEach(function () {
$this->user = User::factory()->create(['is_admin' => true]);
$this->actingAs($this->user);
});
it('can render the list page', function () {
livewire(ListPosts::class)
->assertSuccessful();
});
(, function () {
= ::()->()->();
(::)
->();
});
(, function () {
::()->([ => ]);
(::)
->();
});
(, function () {
= ::()->([ => ]);
= ::()->([ => ]);
(::)
->()
->([])
->([]);
});
(, function () {
= ::()->()->();
(::)
->()
->(->(), : )
->(, )
->(->(), : );
});
(, function () {
= ::()->([ => ]);
= ::()->([ => ]);
(::)
->(, )
->([])
->([]);
});
(, function () {
= ::()->()->();
(::)
->(::, );
( ) {
->();
}
});
<?php
declare(strict_types=1);
use App\Filament\Resources\PostResource;
use App\Filament\Resources\PostResource\Pages\CreatePost;
use App\Models\Category;
use App\Models\Post;
use App\Models\User;
use function Pest\Livewire\livewire;
beforeEach(function () {
$this->user = User::factory()->create(['is_admin' => true]);
$this->actingAs($this->user);
});
it('can render the create page', function () {
livewire(CreatePost::class)
->assertSuccessful();
});
it('can create a post', function () {
$category = Category::()->();
= [
=> ,
=> ,
=> ,
=> ,
=> ->id,
];
(::)
->()
->()
->();
->(::, [
=> ,
=> ,
]);
});
(, function () {
(::)
->([
=> ,
=> ,
])
->()
->([
=> ,
=> ,
]);
});
(, function () {
(::)
->([
=> (, ),
])
->()
->([ => ]);
});
(, function () {
::()->([ => ]);
(::)
->([
=> ,
=> ,
=> ,
])
->()
->([ => ]);
});
<?php
declare(strict_types=1);
use App\Filament\Resources\PostResource;
use App\Filament\Resources\PostResource\Pages\EditPost;
use App\Models\Post;
use App\Models\User;
use Filament\Actions\DeleteAction;
use function Pest\Livewire\livewire;
beforeEach(function () {
$this->user = User::factory()->create(['is_admin' => true]);
$this->actingAs($this->user);
});
it('can render the edit page', function () {
$post = Post::factory()->create();
livewire(EditPost::class, ['record' => $post->()])
->();
});
(, function () {
= ::()->();
(::, [ => ->()])
->([
=> ->title,
=> ->slug,
=> ->content,
=> ->status,
]);
});
(, function () {
= ::()->();
= [
=> ,
=> ,
=> ,
=> ,
];
(::, [ => ->()])
->()
->()
->();
(->())
->title->()
->slug->()
->status->();
});
(, function () {
= ::()->();
(::, [ => ->()])
->(::);
->();
});
(, function () {
= ::()->([ => ]);
= ::()->([ => ]);
(::, [ => ->()])
->([ => ])
->()
->([ => ]);
});
<?php
declare(strict_types=1);
use App\Filament\Resources\PostResource\Pages\ViewPost;
use App\Models\Post;
use App\Models\User;
use function Pest\Livewire\livewire;
beforeEach(function () {
$this->user = User::factory()->create(['is_admin' => true]);
$this->actingAs($this->user);
});
it('can render the view page', function () {
$post = Post::factory()->create();
livewire(ViewPost::class, ['record' => $post->getRouteKey()])
->assertSuccessful();
});
it('can retrieve post data in infolist', function () {
$post = Post::()->([
=> ,
=> ,
]);
(::, [ => ->()])
->()
->();
});
<?php
declare(strict_types=1);
use App\Filament\Resources\PostResource\Pages\CreatePost;
use App\Models\Category;
use App\Models\Tag;
use function Pest\Livewire\livewire;
it('can fill form fields', function () {
$category = Category::factory()->create();
livewire(CreatePost::class)
->fillForm([
'title' => 'Test Title',
'category_id' => $category->id,
])
->assertFormSet([
'title' => 'Test Title',
'category_id' => $category->id,
]);
});
it('has required form fields', function () {
livewire(CreatePost::class)
->assertFormFieldExists('title')
->()
->()
->()
->();
});
(, function () {
= ::()->()->();
(::)
->(, function () ($) {
$->() === $->('', '')->();
});
});
(, function () {
(::)
->([
=> [
[ => , => ],
[ => , => ],
],
])
->()
->();
});
<?php
declare(strict_types=1);
use App\Filament\Resources\PostResource\Pages\ListPosts;
use App\Models\Post;
use function Pest\Livewire\livewire;
it('displays correct columns', function () {
Post::factory()->create([
'title' => 'Test Post',
'status' => 'published',
]);
livewire(ListPosts::class)
->assertCanRenderTableColumn('title')
->assertCanRenderTableColumn('status')
->assertCanRenderTableColumn('author.name')
->assertCanRenderTableColumn('created_at');
});
it('can filter by date range', function () {
$oldPost = Post::factory()->create([
'created_at' => now()->subMonths(),
]);
= ::()->([
=> (),
]);
(::)
->(, [
=> ()->()->(),
=> ()->(),
])
->([])
->([]);
});
(, function () {
(::)
->();
});
<?php
declare(strict_types=1);
use App\Filament\Resources\PostResource\Pages\EditPost;
use App\Filament\Resources\PostResource\Pages\ListPosts;
use App\Models\Post;
use Filament\Tables\Actions\DeleteAction;
use function Pest\Livewire\livewire;
it('can call publish action', function () {
$post = Post::factory()->create(['status' => 'draft']);
livewire(EditPost::class, ['record' => $post->getRouteKey()])
->callAction('publish');
expect($post->refresh()->status)->toBe('published');
});
it(, function () {
= ::()->([ => ]);
= ::()->([ => ]);
(::, [ => ->()])
->();
(::, [ => ->()])
->();
});
(, function () {
= ::()->();
(::)
->(::, );
->();
});
(, function () {
= ::()->();
(::, [ => ->()])
->(, [
=> ,
=> ,
])
->();
});
(, function () {
= ::()->();
(::, [ => ->()])
->(, [
=> ,
=> ,
])
->([
=> ,
=> ,
]);
});
<?php
declare(strict_types=1);
use App\Filament\Resources\PostResource\Pages\CreatePost;
use App\Filament\Resources\PostResource\Pages\EditPost;
use App\Filament\Resources\PostResource\Pages\ListPosts;
use App\Models\Post;
use App\Models\User;
use function Pest\Livewire\livewire;
it('prevents unauthorized users from viewing list', function () {
$user = User::factory()->create(['is_admin' => false]);
$this->actingAs($user);
livewire(ListPosts::class)
->assertForbidden();
});
it(, function () {
= ::()->([ => ]);
->();
(::)
->();
});
(, function () {
= ::()->();
= ::()->();
= ::()->([ => ->id]);
->();
(::, [ => ->()])
->();
});
(, function () {
= ::()->();
= ::()->([ => ->id]);
->();
(::, [ => ->()])
->();
});
<?php
declare(strict_types=1);
use App\Filament\Widgets\StatsOverview;
use App\Filament\Widgets\LatestPosts;
use App\Models\Post;
use App\Models\User;
use function Pest\Livewire\livewire;
it('can render stats overview widget', function () {
livewire(StatsOverview::class)
->assertSuccessful();
});
it('displays correct stats', function () {
Post::factory()->count(5)->create(['status' => 'published']);
Post::factory()->count(3)->create(['status' => 'draft']);
livewire(StatsOverview::class)
->()
->();
});
(, function () {
= ::()->()->();
(::)
->()
->();
});
<?php
declare(strict_types=1);
use App\Filament\Resources\PostResource\RelationManagers\CommentsRelationManager;
use App\Models\Comment;
use App\Models\Post;
use function Pest\Livewire\livewire;
it('can render relation manager', function () {
$post = Post::factory()->create();
livewire(CommentsRelationManager::class, [
'ownerRecord' => $post,
'pageClass' => \App\Filament\Resources\PostResource\Pages\EditPost::class,
])
->assertSuccessful();
});
it('can list related comments', function () {
$post = Post::factory()->create();
$comments = Comment::factory()->count(3)->([ => ->id]);
(::, [
=> ,
=> ::,
])
->();
});
(, function () {
= ::()->();
(::, [
=> ,
=> ::,
])
->(, : [
=> ,
]);
(->comments)->();
});
Generated tests include: