Remove hardcoded Redis URL from tests

- Read REDIS_URL from environment
- Skip tests if not set
This commit is contained in:
2026-03-28 09:43:34 +00:00
parent f4aafb1095
commit baad4a271a

View File

@@ -17,14 +17,22 @@ use PHPUnit\Framework\TestCase;
/** /**
* Tests for Redis-backed caching. * Tests for Redis-backed caching.
*
* Requires REDIS_URL environment variable. Tests will skip if not set.
*/ */
class RedisCacheTest extends TestCase class RedisCacheTest extends TestCase
{ {
private CacheInterface $redisCache; private CacheInterface $redisCache;
private string $redisUrl = 'REDIS_URL_FROM_ENV'; private ?string $redisUrl = null;
protected function setUp(): void 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:'); $this->redisCache = RedisCache::fromUrl($this->redisUrl, 'test_ctx:');
} }