mcpField
T
tdd-with-phpunit

tdd-with-phpunit

github.com/dev-toolingsTesting & quality227102 installsUpdated 3w ago
Repository

About tdd-with-phpunit

tdd-with-phpunit is a Symfony testing skill for developers using PHPUnit 10 or 11. It guides RED-GREEN-REFACTOR tests for application behavior, commands, forms, and external service boundaries, with explicit output and version guardrails.

Key features

  1. 01RED-GREEN-REFACTOR workflow
  2. 02Choosing Symfony test base classes
  3. 03Testing commands and invalid forms
  4. 04Replacing external services with doubles
  5. 05PHPUnit attribute and version guidance

Use cases

  1. 01Developing a Symfony feature test-first
  2. 02Selecting a test class for new behavior
  3. 03Testing console commands and 422 forms
  4. 04Mocking an external service through the test container

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/dev-toolings/superpowers-symfony --skill tdd-with-phpunit

After installing, type/tdd-with-phpunitin Claude Code to confirm it loaded.

Bundled filesreference.md

Details

From the project README

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

Comments

Markdown supported