Prophecy is a mocking framework for PHP that provides a highly opinionated approach to creating test doubles with a fluent, semantically meaningful API.
The framework addresses the need for flexible object mocking in unit tests by using a "prophecy" metaphor where developers describe expected future behavior of objects with limited prior knowledge. The core workflow involves creating an ObjectProphecy through a Prophet object, specifying what class the mock should extend or interfaces it should implement, then revealing the prophecy as a usable test double. The framework distinguishes between dummies (objects that do nothing and return null for all method calls), stubs (dummies with method-specific behavior logic), and mocks (objects with explicit expectations about how they will be called).
Prophecy suits developers working within any PHP testing framework who want a semantically clear mocking API where terminology carries logical meaning. The framework was originally created to serve phpspec2 but is flexible enough for standalone use. It works well when you need token objects to satisfy type hints without caring about behavior, when you want stubs with specific return values for different method signatures, or when you need mocks with strict expectations about method invocations. The README emphasizes that understanding the semantic naming convention—where "prophecy" describes future behavior, "prophet" creates prophecies, and "revealing" produces usable doubles—is key to becoming fluent with the tool.
The project maintains active engagement with its codebase through regular commits addressing both bug fixes and feature refinements. Pull requests receive timely review and feedback from maintainers, indicating responsive stewardship. The issue tracker shows consistent attention to user-reported problems and feature requests, with maintainers providing detailed explanations and guidance. Documentation is kept current alongside code changes, and the project demonstrates a commitment to supporting multiple PHP versions through ongoing compatibility work.