From fuse-php
Use when writing or configuring tests on a framework-agnostic PHP project and choosing between PHPUnit and Pest. Covers PHPUnit 12 attributes, Pest 4, test doubles, fixtures, and coverage. Do NOT use for Laravel test helpers (RefreshDatabase, HTTP tests → laravel-expert laravel-testing) or quality tooling (PHPStan/Rector/Fixer → php-quality-tooling).
How this skill is triggered — by the user, by Claude, or both
Slash command
/fuse-php:php-testingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Two frameworks, one engine. Pest is a layer over PHPUnit — both need **PHP 8.3+**
Two frameworks, one engine. Pest is a layer over PHPUnit — both need PHP 8.3+ and share the same runner and assertions underneath.
Before ANY implementation, use TeamCreate to spawn 3 agents:
After implementation, run fuse-ai-pilot:sniper for validation.
| Framework | Style | Strength |
|---|---|---|
| PHPUnit 12 | Class-based, xUnit | Enterprise baseline, explicit, widest tooling/CI support |
| Pest 4 | Closure-based, expressive | Modern DX, browser + arch + mutation testing, less boilerplate |
Pest 4 runs on PHPUnit's engine, so PHPUnit knowledge transfers directly. The choice is about ergonomics and team preference, not capability.
@test, @dataProvider)public static - Non-static providers no longer workcreateStub() is not configurable - Configure expectations only on createMock()Choosing a framework? (non-Laravel)
├── Enterprise / strict CI / mixed team → PHPUnit 12 (explicit, ubiquitous)
├── Modern DX, greenfield, small team → Pest 4 (concise, expressive)
├── Need browser / architecture / mutation testing out of the box → Pest 4
└── Migrating a large PHPUnit suite → stay PHPUnit, or drift-migrate to Pest
Honest note: PHPUnit is the enterprise/CI baseline; Pest has strong community momentum but that trend is not normative. Either is a correct, well-supported choice — pick per team, not per hype.
→ Full matrix in references/choosing-framework.md
| Topic | Reference | Load when |
|---|---|---|
| Framework choice | references/choosing-framework.md | Deciding PHPUnit vs Pest |
| PHPUnit 12 | references/phpunit-12.md | Writing PHPUnit tests |
| Pest 4 | references/pest-4.md | Writing Pest tests |
| Annotation migration | references/annotations-to-attributes.md | Upgrading pre-12 tests |
| Template | Use Case |
|---|---|
references/templates/phpunit-xml.md | phpunit.xml + first TestCase |
references/templates/pest-setup.md | Pest.php + first Pest tests |
references/templates/test-doubles.md | Stubs, mocks, fixtures, coverage |
use PHPUnit\Framework\TestCase;
final class GreeterTest extends TestCase
{
public function testGreets(): void
{
$this->assertSame('Hi, Al', (new Greeter)->greet('Al'));
}
}
it('greets', function () {
expect((new Greeter)->greet('Al'))->toBe('Hi, Al');
});
testRejectsExpiredToken), assert one behavior each#[DataProvider] with public static providers for table-driven tests@test / @dataProvider annotations (removed in PHPUnit 12)createStub() resultsnpx claudepluginhub fusengine/agents --plugin fuse-phpPHPUnit and Pest patterns for any PHP project: test structure, naming, data providers, test doubles (mocks/stubs/fakes), fixtures, and coverage targets. Stack-agnostic — referenced by every PHP plugin in the marketplace. Use this skill to: - Structure unit and integration tests with PHPUnit or Pest consistently. - Drive cases with data providers / datasets instead of copy-pasted test bodies. - Use test doubles with discipline — mock collaborators, not the system under test. - Set up and tear down fixtures cleanly and aim for a meaningful coverage target. Do NOT use this skill for: - PHP language idioms — see php-foundation:php-conventions. - Composer / autoloading — see php-foundation:composer-tooling. - Framework-specific test helpers (Laravel RefreshDatabase/actingAs, Symfony WebTestCase/KernelTestCase) — those are injected by the framework plugin's QA phase.
PHPUnit testing framework conventions and practices. Invoke whenever task involves any interaction with PHPUnit — writing tests, configuring PHPUnit, data providers, mocking, assertions, debugging test failures, or coverage.
Provides testing patterns for Laravel 13 with Pest PHP 4 or PHPUnit 12. Covers HTTP tests, model factories, database assertions, facade mocking, authentication testing, and test organization.