mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Updated RedisFactory so that it loads redis config from cache.redis too
This commit is contained in:
parent
406f947096
commit
c9be89647c
2 changed files with 21 additions and 2 deletions
|
@ -16,7 +16,8 @@ class RedisFactory
|
|||
|
||||
public function __invoke(ContainerInterface $container): PredisClient
|
||||
{
|
||||
$redisConfig = $container->get('config')['redis'] ?? [];
|
||||
$config = $container->get('config');
|
||||
$redisConfig = $config['cache']['redis'] ?? $config['redis'] ?? [];
|
||||
|
||||
$servers = $redisConfig['servers'] ?? [];
|
||||
$servers = is_string($servers) ? explode(',', $servers) : $servers;
|
||||
|
|
|
@ -27,7 +27,7 @@ class RedisFactoryTest extends TestCase
|
|||
* @test
|
||||
* @dataProvider provideRedisConfig
|
||||
*/
|
||||
public function createsRedisClientBasedOnConfig(?array $config, string $expectedCluster): void
|
||||
public function createsRedisClientBasedOnRedisConfig(?array $config, string $expectedCluster): void
|
||||
{
|
||||
$getConfig = $this->container->get('config')->willReturn([
|
||||
'redis' => $config,
|
||||
|
@ -39,6 +39,24 @@ class RedisFactoryTest extends TestCase
|
|||
$this->assertInstanceOf($expectedCluster, $client->getOptions()->cluster);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideRedisConfig
|
||||
*/
|
||||
public function createsRedisClientBasedOnCacheConfig(?array $config, string $expectedCluster): void
|
||||
{
|
||||
$getConfig = $this->container->get('config')->willReturn([
|
||||
'cache' => [
|
||||
'redis' => $config,
|
||||
],
|
||||
]);
|
||||
|
||||
$client = ($this->factory)($this->container->reveal());
|
||||
|
||||
$getConfig->shouldHaveBeenCalledOnce();
|
||||
$this->assertInstanceOf($expectedCluster, $client->getOptions()->cluster);
|
||||
}
|
||||
|
||||
public function provideRedisConfig(): iterable
|
||||
{
|
||||
yield 'no config' => [null, PredisCluster::class];
|
||||
|
|
Loading…
Add table
Reference in a new issue