Skip to content
Back to skills

Tdd With Phpunit

ASecurity

Apply RED-GREEN-REFACTOR with PHPUnit 10/11 for Symfony; KernelTestCase/WebTestCase, attributes (#[Test]/#[DataProvider]), Foundry

  • 221 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added August 31, 2026
developmentphpshellbashrailstestingdatabase

Works with

  • cli

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned October 6, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Tdd With Phpunit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Tdd With Phpunit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dev-toolings-tdd-with-phpunit/badge)](https://www.skillsdirectory.com/skills/dev-toolings-tdd-with-phpunit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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`

Files in this skill

  • SKILL.md1.1 KB
  • reference.md6.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.