rodrigodiez/mockable-predis

A class that extends Predis/Client and has all its magic methods anotated so you can create Prophecy mocks

1.0.4 2016-02-16 19:57 UTC

This package is not auto-updated.

Last update: 2024-05-25 16:55:51 UTC


README

Build Status SensioLabsInsight Packagist Downloads

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.