josiasmontag / laravel-redis-mock by josiasmontag

This Laravel package provides a Redis mock for your tests
1,219,223
44
3
Package Data
Maintainer Username: josiasmontag
Maintainer Contact: josias@montag.info (Josias Montag)
Package Create Date: 2017-11-03
Package Last Update: 2024-03-04
Language: PHP
License: MIT
Last Refreshed: 2024-11-21 03:01:27
Package Statistics
Total Downloads: 1,219,223
Monthly Downloads: 36,183
Daily Downloads: 1,667
Total Stars: 44
Total Watchers: 3
Total Forks: 10
Total Open Issues: 1

Laravel Redis Mock

This Laravel package provides a Redis mock for your tests. It depends on Redis PHP Mock.

Installation & Usage

To get started, use Composer to add the package to your project's dependencies:

composer require josiasmontag/laravel-redis-mock

This package adds a new mock Redis client.

In config/database.php, make the Redis client configurable via environment variable:

    'redis' => [

        'client' => env('REDIS_CLIENT', 'predis'),

        ...
        
    ],

Now, you can switch to the mock client in your .env.testing:

REDIS_CLIENT=mock

Alternatively, you can switch to the mock in your phpunit.xml:

<env name="REDIS_CLIENT" value="mock"/>

Done! Your tests should work without a local redis server running.