Skip to main content
skill CX Codex

tdd-with-phpunit — Claude Code skill: what it does, how to install

The tdd-with-phpunit skill guides PHPUnit-driven work on Symfony features, from checking a failing test to refactoring after it passes. Use it for command, form, and external-service tests.

MIT ★ 234 updated 2026-10-05

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add dev-toolings/superpowers-symfony --skill tdd-with-phpunit -a claude-code
Open on GitHub

What tdd-with-phpunit does

The skill lays out a RED-GREEN-REFACTOR workflow for PHPUnit 10/11 and helps select TestCase, KernelTestCase, or WebTestCase. It covers console command checks, 422 responses from invalid forms, and replacing an external dependency through Symfony’s test container. The agent’s output should include the failing and passing test runs, changed test files, and commands it ran.

New tests use PHPUnit attributes such as #[Test] and #[DataProvider]; the skill rules out the older @test and @dataProvider annotations. It recommends keeping real services and the database in place, while substituting mocks only at external boundaries. runCommand() and closures passed to getContainer()->set() require Symfony 8.1+, so that approach won’t work on earlier versions.

What it helps with

  • drive Symfony feature work with the RED-GREEN-REFACTOR cycle
  • choose a base class for a PHPUnit test
  • check a console command with CommandTester
  • assert a 422 response for an invalid form
  • replace an external HTTP client with a test double

Example prompts for the agent

  • Write a PHPUnit test for this Symfony feature, then work through RED-GREEN-REFACTOR.
  • Test this console command with CommandTester and show the test run.
  • Add a test expecting a 422 response for this invalid form, and replace the external service with a test double.

How to install tdd-with-phpunit

1Skills CLI (Vercel)

npx skills add dev-toolings/superpowers-symfony --skill tdd-with-phpunit -a claude-code

2Manually: put the files in place

~/.claude/skills/tdd-with-phpunit/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/tdd-with-phpunit/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about tdd-with-phpunit

How do I install tdd-with-phpunit in Claude Code?

Run npx skills add dev-toolings/superpowers-symfony --skill tdd-with-phpunit -a claude-code. The skill file is at ~/.claude/skills/tdd-with-phpunit/SKILL.md.

What does tdd-with-phpunit do?

It guides Symfony testing with PHPUnit 10/11, including the RED-GREEN-REFACTOR cycle, test base-class selection, and external dependency substitution.

Which Symfony version supports runCommand() in this skill?

Use Symfony 8.1 or later for runCommand() and closures passed to getContainer()->set().

Source text

SKILL.md · MIT
---
name: tdd-with-phpunit
description: Apply RED-GREEN-REFACTOR with PHPUnit 10/11 for Symfony; KernelTestCase/WebTestCase, attributes (#[Test]/#[DataProvider]), Foundry
capabilities: [read, search, edit, shell]
tags: [testing, tdd]
# projected by `bun run build` — do not edit by hand
allowed-tools:
  - Read
  - Glob
  - Grep
  - Write
  - Edit
  - Bash
---

# Tdd With Phpunit (Symfony)

## Use when
- Driving a feature with RED-GREEN-REFACTOR using PHPUnit 10/11 class-based tests.
- Choosing between `TestCase`, `KernelTestCase` and `WebTestCase` for a new behavior.
- Testing a console command, or an invalid form that must answer 422.
- Swapping an external service for a double through the test container.

## Default workflow
1. RED: pick the base class, write the test with `#[Test]`, `#[DataProvider]` and `#[CoversClass]`, run it and check it fails for the right reason.
2. GREEN: write the minimum code that passes.
3. REFACTOR with the suite green, re-running it after each change.
4. Replace an external boundary with `static::getContainer()->set(Service::class, $mock)`.
5. Test commands with `CommandTester`, or with `runCommand()` and `assertCommandIsSuccessful()` on Symfony 8.1+.
6. Assert invalid form submissions with `assertResponseIsUnprocessable()`.

## Guardrails
- Use PHPUnit 10+ attributes, not `@test` or `@dataProvider` annotations.
- Fetch services with `static::getContainer()`, not the legacy `self::$container`.
- Mock only true external boundaries (HTTP clients, third-party SDKs); keep real services and a real database elsewhere.
- `runCommand()` and closures in `getContainer()->set()` need Symfony 8.1+.

## Progressive disclosure
- Use this file for execution posture and risk controls.
- Open references when deep implementation details are needed.

## Output contract
- The failing PHPUnit output (RED), then the passing run.
- Test files changed, with the base class and attributes used.
- Commands executed.

## References
- `reference.md`

© dev-toolings · MIT · dev-toolings/superpowers-symfony

Similar skills

All skills for Testing and QA →

From the same set51

The whole set →
brainstorming brainstorming structures feature discovery for Symfony projects: clarifies unclear requirements, identifies framework components, and compares architecture designs. CX Codex +1 ★ 234repo stars runner-selection The runner-selection skill detects whether Symfony commands belong in Docker, DDEV, or the host environment. Use it when the right command prefix is unclear or containers may be stopped. CX Codex +1 ★ 234repo stars doctrine-events doctrine-events — a Claude skill for attaching side effects to Doctrine entity events in Symfony: timestamps, slugs, search index updates, notifications. CX Codex +1 ★ 234repo stars form-types-validation form-types-validation generates Symfony form types, configures DTO validation groups, handles HTTP 422 responses, and sets up multi-step flows. CX Codex +1 ★ 234repo stars using-symfony-superpowers using-symfony-superpowers is a Claude Code skill that detects the Symfony version, selects a skill, and sequences steps for complex tasks. CX Codex +1 ★ 234repo stars interfaces-and-autowiring interfaces-and-autowiring guides Symfony dependency injection in Claude Code by binding interfaces, configuring #[Target] aliases, and decorating services cleanly. CX Codex +1 ★ 234repo stars symfony-cache Configure Symfony Cache pools, entry expiry, and tag-based invalidation with this skill. It helps when caching costly reads or preventing a burst of recomputations after a key expires. CX Codex +1 ★ 234repo stars test-doubles-mocking test-doubles-mocking — a skill for creating test doubles with PHPUnit mocks in Symfony, used to replace slow or external dependencies, verify method calls, and write simplified repository fakes in isolated unit tests. CX Codex +1 ★ 234repo stars

Project sponsors

Companies that keep this analytics open