symfony:test-doubles-mocking

Create deterministic Symfony tests using PHPUnit and Prophecy test doubles.

187|17|Updated Dec 17, 2025
One-click install
npx skills add https://github.com/MakFly/superpowers-symfony --skill symfony-test-doubles-mocking
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: symfony:test-doubles-mocking
Source: https://github.com/MakFly/superpowers-symfony/tree/main/skills/test-doubles-mocking
Command: npx skills add https://github.com/MakFly/superpowers-symfony --skill symfony-test-doubles-mocking

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers create deterministic and regression-safe tests for Symfony applications by effectively using test doubles like mocks and stubs.

Core Features & Use Cases

  • Test Double Strategies: Learn to use Dummies, Stubs, Mocks, Spies, and Fakes.
  • PHPUnit & Prophecy: Examples for both popular PHP testing frameworks.
  • Symfony Service Mocking: Specific guidance on mocking Doctrine, Repositories, and Message Buses.
  • Use Case: When developing a new feature, use this Skill to ensure your new code doesn't break existing functionality by writing tests that isolate components and verify interactions.

Quick Start

Use the symfony:test-doubles-mocking skill to generate a PHPUnit mock for the PaymentGateway service.

Frequently Asked Questions about symfony:test-doubles-mocking

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I mock Symfony services like EntityManager in PHPUnit tests?

To mock Symfony services in PHPUnit, create test doubles for the EntityManager. This Skill provides specific examples to isolate components and ensure regression protection by mocking Doctrine services and repository interactions deterministically.

What is the difference between using test doubles, stubs, and mocks in Symfony?

Test doubles is an umbrella term for isolating components. This Skill clarifies the difference by demonstrating how to use Dummies, Stubs, Mocks, Spies, and Fakes to build deterministic and regression-safe Symfony tests.

Can I use Prophecy instead of PHPUnit for mocking Symfony applications?

Yes, you can use Prophecy for mocking Symfony applications. This Skill covers test double strategies and provides practical examples for both popular PHP testing frameworks to help you isolate components effectively.

How do I create a deterministic test for a Symfony MessageBus?

To create a deterministic test for a Symfony MessageBus, use test doubles to mock the bus interactions. This Skill offers specific guidance on mocking Message Buses to isolate components and verify interactions without external side effects.

Why are my Symfony unit tests failing due to external dependencies?

Symfony unit tests fail from external dependencies when components are not properly isolated. Using test doubles like mocks and stubs ensures regression protection by making tests deterministic and isolating the specific component being verified.