josiasmontag / laravel-redis-mock by josiasmontag

This Laravel package provides a Redis mock for your tests
1,252,171
45
4
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-12-21 03:01:29
Package Statistics
Total Downloads: 1,252,171
Monthly Downloads: 31,115
Daily Downloads: 970
Total Stars: 45
Total Watchers: 4
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.