php-testing
БесплатноБез исполняемых скриптовНе проверенUse when writing/configuring tests on a non-Laravel PHP project — PHPUnit vs Pest. Do NOT use for Laravel test helpers or quality tooling (php-quality-tooling).
от Fusengine★ 36 звёзд на GitHubОб этом скилле
Includes a decision matrix for choosing between the two (team preference, not capability), plus templates for phpunit.xml, Pest.php setup, and test doubles (stubs, mocks, fixtures, coverage).
Do NOT use this skill for Laravel test helpers such as RefreshDatabase or HTTP testing — those are covered by laravel-expert's laravel-testing skill. Do NOT use it for static analysis or formatting tooling — that is php-quality-tooling.
PHP Testing
Two frameworks, one engine. Pest is a layer over PHPUnit — both need PHP 8.4+ and share the same runner and assertions underneath.
Agent Workflow (MANDATORY)
Before ANY implementation, spawn 3 agents in parallel, one Agent call each with a name:
- fuse-ai-pilot:explore-codebase - Detect existing framework (phpunit.xml vs Pest.php), test layout, PHP version
- fuse-ai-pilot:research-expert - Verify latest PHPUnit 13 / Pest 5 docs via Context7/Exa
- mcp__context7__query-docs - Check attribute names, test-double API, config schema
After implementation, run fuse-ai-pilot:sniper for validation.
Overview
| Framework | Style | Strength |
|---|---|---|
| PHPUnit 13 | Class-based, xUnit | Enterprise baseline, explicit, widest tooling/CI support |
| Pest 5 | Closure-based, expressive | Modern DX, browser + arch + mutation testing, less boilerplate |
Pest 5 runs on PHPUnit 13's engine, so PHPUnit knowledge transfers directly. The choice is about ergonomics and team preference, not capability.
Critical Rules
- PHP 8.4+ required - Both PHPUnit 13 and Pest 5 drop PHP 8.3 (stay on PHPUnit 12 / Pest 4 for 8.3)
- Attributes only, no annotations - PHPUnit 12 removed docblock annotations (
@test,@dataProvider) - Data providers are
public static- Non-static providers no longer work createStub()is not configurable - Configure expectations only oncreateMock();any()is hard-deprecated in PHPUnit 13 — use a stub or a real count (once(),exactly(n))- One framework per project - Pest or PHPUnit, not both driving the same suite
- Mock at boundaries - Network/DB/clock, never internal implementation detail
Decision Guide
Choosing a framework? (non-Laravel)
├── Enterprise / strict CI / mixed team → PHPUnit 13 (explicit, ubiquitous)
├── Modern DX, greenfield, small team → Pest 5 (concise, expressive)
├── Need browser / architecture / mutation testing out of the box → Pest 5
└── 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
Reference Guide
Concepts
| Topic | Reference | Load when |
|---|---|---|
| Framework choice | references/choosing-framework.md |
Deciding PHPUnit vs Pest |
| PHPUnit 13 | references/phpunit-12.md |
Writing PHPUnit tests |
| Pest 5 | references/pest-4.md |
Writing Pest tests |
| Annotation migration | references/annotations-to-attributes.md |
Upgrading pre-12 tests |
Templates
| 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 |
Quick Start
PHPUnit 13
use PHPUnit\Framework\TestCase;
final class GreeterTest extends TestCase
{
public function testGreets(): void
{
$this->assertSame('Hi, Al', (new Greeter)->greet('Al'));
}
}
Pest 5
it('greets', function () {
expect((new Greeter)->greet('Al'))->toBe('Hi, Al');
});
Best Practices
DO
- Name tests by behavior (
testRejectsExpiredToken), assert one behavior each - Use
#[DataProvider]withpublic staticproviders for table-driven tests - Gate CI on an explicit coverage threshold, not a report
DON'T
- Keep
@test/@dataProviderannotations (removed in PHPUnit 12) - Configure expectations on
createStub()results - Mock the class under test — mock its collaborators
Установить php-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл php-testing?
Use when writing/configuring tests on a non-Laravel PHP project — PHPUnit vs Pest. Do NOT use for Laravel test helpers or quality tooling (php-quality-tooling).
Как установить скилл php-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл php-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic