rodrigodiez / mockable-predis
A class that extends Predis/Client and has all its magic methods anotated so you can create Prophecy mocks
Requires
- predis/predis: ~1.0
Requires (Dev)
- phpspec/phpspec: ~2.0
- squizlabs/php_codesniffer: ~2.0
This package is not auto-updated.
Last update: 2025-05-24 23:09:38 UTC
README
Mockable Predis
This project allows developers to use PhpSpec/Prophecy to TDD projects that use Predis by allowing mocks of the Client to be created.
Installation
composer require rodrigodiez/mockable-predis
Use
Just use RodrigoDiez\MockablePredis\Client
class in your code instead of Predis\Client
Why is this needed?
Predis makes intensive use of magic call methods in its Client
class making it impossible for some mocking frameworks to guess its interface and create mocks.
One common workaround when using magic call methods within a class is to document them using @method
annotations as described here
Predis maintainers decided to document these methods in the ClientInterface
instead of doing it in the Client
class itself as recommended by phpdoc documentation. On the other hand, Prophecy maintainers refuse to read @method
annotations from interfaces.
Full history and both sides arguments can be found here and here.