josiasmontag/laravel-redis-mock

This Laravel package provides a Redis mock for your tests

Maintainers

👁 josiasmontag

Package info

github.com/josiasmontag/laravel-redis-mock

pkg:composer/josiasmontag/laravel-redis-mock

Statistics

Installs: 1 857 532

Dependents: 15

Suggesters: 0

Stars: 47

Open Issues: 2

1.3.6 2026-02-24 08:17 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 7161a3af919fb7a60fbf47c0b60d6d05ad5d6b9b

  • Josias Montag <josias.woop@montag.info>

phplanguagelaravellocalization

This package is auto-updated.

Last update: 2026-06-05 11:09:05 UTC


README

👁 Build Status
👁 Total Downloads
👁 Latest Stable Version
👁 License

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

This makes it possible to run your tests without any local Redis server running!

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.

Package Development

If you are using Redis as part of a Laravel package, you should already have a TestCase.php that is extending Orchestra\Testbench\Testcase.

Within this file you should add RedisMockServiceProvider to getPackageProviders method e.g.

 /**
 * @param $app
 * @return string[]
 */
 protected function getPackageProviders($app): array
 {
 return [
 YourPackageServiceProvider::class,
 \Lunaweb\RedisMock\Providers\RedisMockServiceProvider::class
 ];
 }