Remove hardcoded Redis URL from tests
- Read REDIS_URL from environment - Skip tests if not set
This commit is contained in:
@@ -17,14 +17,22 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Tests for Redis-backed caching.
|
||||
*
|
||||
* Requires REDIS_URL environment variable. Tests will skip if not set.
|
||||
*/
|
||||
class RedisCacheTest extends TestCase
|
||||
{
|
||||
private CacheInterface $redisCache;
|
||||
private string $redisUrl = 'REDIS_URL_FROM_ENV';
|
||||
private ?string $redisUrl = null;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->redisUrl = getenv('REDIS_URL') ?: null;
|
||||
|
||||
if ($this->redisUrl === null) {
|
||||
$this->markTestSkipped('REDIS_URL not set, skipping Redis tests');
|
||||
}
|
||||
|
||||
$this->redisCache = RedisCache::fromUrl($this->redisUrl, 'test_ctx:');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user