/phpunit:php-tdd-workflowfrom phpunit
Provides PHP/Symfony-specific TDD workflow examples and commands, covering Symfony iteration patterns, PHPUnit data providers, and end-of-iteration checklist.
Ships in phpunit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The cross-language TDD process (cross-layer iterations, RED-GREEN-REFACTOR, working-app-at-each-GREEN, bug-fix workflow, mocks-hiding-bugs) is defined in
craft:tdd-workflow-principles. This skill keeps PHP/Symfony/PHPUnit-specific examples and commands.
For test writing conventions (DAMP, Prophecy, factories), see
php-test-conventions.
"New Discount" feature — each iteration touches whatever layer is needed next:
WebTestCase): authenticated user gets 200. Implement: empty controller with route.true. Implement: IsBuyerEligibleForDiscount.canApplyDiscount() returns correct value. Implement: component method.After GREEN, when multiple tests have the same AAA structure and only differ in input data, consolidate. Criterion: no if in the test body.
/**
* @test
* @dataProvider provideValidSelections
*/
public function formIsValid(array $selection): void
{
$form = $this->factory->create(MyForm::class);
$form->submit(['type' => $selection]);
self::assertTrue($form->isValid());
}
public static function provideValidSelections(): \Generator
{
yield 'initialPaymentOnly' => ['selection' => ['initial_payment']];
yield 'scheduledPaymentOnly' => ['selection' => ['scheduled_payment']];
}
At the end of each GREEN, in addition to the cross-language checklist (see craft:tdd-workflow-principles):
| Check | PHP/Symfony action |
|---|---|
| Template referenced? | Create the file (even empty) |
| Service injected? | Declare in services.yaml |
| Interface used? | Implement or create a stub |
| Route added? | Verify with bin/console debug:router |
# After each GREEN, verify the app starts
docker compose exec php bin/console cache:clear
docker compose exec php bin/console lint:container
// Mocks hide real issues
$serializer = $this->prophesize(SerializerInterface::class);
$serializer->deserialize(...)->willReturn($expectedResponse); // Always passes
// Real dependencies expose them
$serializer = $this->createSerializer();
$result = $httpClient->__invoke(); // Fails if deserialization is broken
Whether a unit earns a test at all is craft:testing-principles' call, not this table's. Once a test is earned, these are the PHP/Symfony defaults:
| Code Created | Default level |
|---|---|
| Feature class | Unit test for business logic |
| Controller | Functional test (WebTestCase) for endpoint |
| Repository | Integration test with database (KernelTestCase) |
| Specification | Unit test for each rule |
| Serialization carrying its own mapping or format rules | Serialization test (in package) — the plain DTO underneath earns none |
# All tests
make php/tests
# Specific test file
docker compose exec php ./vendor/bin/phpunit path/to/Test.php
# Filter by test name
docker compose exec php ./vendor/bin/phpunit --filter=name
# Verify a test fails (RED) before implementing
docker compose run --rm php ./vendor/bin/phpunit path/to/YourTest.php
# Vendor packages (e.g. vendor/acme/*)
cd vendor/acme/<package>/ && docker compose run --rm php ./vendor/bin/phpunit tests/Path/To/YourTest.php
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub fabiensalles/claude-marketplace --plugin phpunit2 skills in this plugin