Opinionated, flexible object mocking framework for PHP
open sourceMITfree
Prophecy is a PHP object mocking framework, opinionated but flexible. It was first written for phpspec and works inside any test framework; the separate prophecy-phpunit package integrates it with PHPUnit 9.1 and later. You prophesize a class or interface and reveal a test double from it: dummies, stubs whose method prophecies return promised values for wildcarded arguments, mocks whose predictions are checked at the end of a test, and spies that record calls to check afterwards.
Problems it solves
- mock a dependency in my PHPUnit test
- check a PHP method was called with the right arguments in a test
- stub an interface's return values in PHP tests
Features
- dummies, stubs, mocks and spies from one prophecy API
- promises and argument wildcards on method prophecies
- predictions checked at the end of a test
- PHPUnit integration through prophecy-phpunit
Alternatives
The same job
These do what Prophecy does.
