Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Module Redis Laravel Package

codeception/module-redis

Codeception Redis module for functional and acceptance tests. Provides helpers to connect to Redis, flush/select databases, set/get keys, and assert cache and data state during tests, making Redis-backed features easy to verify in your test suite.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing via Composer: composer require --dev codeception/module-redis. Then enable it in your codeception.yml (or environment-specific config) under modules: enabled: [Redis]. Configure connection details under config: Redis: host: '127.0.0.1', port: 6379. Your first use case is typically redis cleanup between tests—e.g., in tests/_support/Helper/Functional.php, call $I->amInRedisDatabase(0); $I->flushRedis(); in _before() to ensure test isolation.

Implementation Patterns

  • Key assertions: Use $I->seeInRedis('user:123'), $I->dontSeeInRedis('session:abc'), or $I->grabFromRedis('key') to inspect Redis state.
  • Database switching: Use amInRedisDatabase($db) to test multi-database setups (default is 0).
  • Typed value checks: Leverage seeHashInRedis('hashkey', ['field' => 'value']) and grabFromRedisAsJson('key') for structured data.
  • Integration with Actor: Add Redis helper methods to FunctionalTester via _support/FunctionalTester.php (e.g., loginViaRedisSession()).
  • Cleanup strategies: Combine with codeception/module-doctrine or codeception/module-phpbrowser for end-to-end tests with layered state dependencies.

Gotchas and Tips

  • ⚠️ Default connection may not match prod: Ensure port, database, and password match your test Redis instance—mismatches cause silent test failures.
  • ⚠️ No persistence safety: flushRedis() wipes all keys in the selected DB—avoid in shared test environments; consider select + flush + targeted del instead.
  • 🔧 Debugging tip: Use $this->getModule('Redis')->getWebDriver()->_getResponse(); (though not applicable here) or var_dump($I->grabFromRedis('key')) to inspect raw data structures—especially for complex types (e.g., ZSETs).
  • 🛠️ Extensibility: Override methods in your _support/Helper/Redis.php to add domain-specific helpers (e.g., createTestUserInRedis($id)).
  • 📦 Limitations: Only basic Redis operations supported—no Lua scripting, streams, or cluster management. For advanced testing, consider predis/predis directly in your tests.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests