diff --git a/src/Symfony/Component/Cache/Tests/Traits/RedisTraitTest.php b/src/Symfony/Component/Cache/Tests/Traits/RedisTraitTest.php index e7e368b3e829d..e07ec82d7cec2 100644 --- a/src/Symfony/Component/Cache/Tests/Traits/RedisTraitTest.php +++ b/src/Symfony/Component/Cache/Tests/Traits/RedisTraitTest.php @@ -17,13 +17,6 @@ class RedisTraitTest extends TestCase { - public static function setUpBeforeClass(): void - { - if (!getenv('REDIS_CLUSTER_HOSTS')) { - throw new SkippedTestSuiteError('REDIS_CLUSTER_HOSTS env var is not defined.'); - } - } - /** * @dataProvider provideCreateConnection */ @@ -65,4 +58,31 @@ public static function provideCreateConnection(): array ], ]; } + + public function testClearUsesValidType() + { + if (!class_exists(\Redis::class)) { + throw new SkippedTestSuiteError(sprintf('The "%s" class is required.', \Redis::class)); + } + $redisMock = $this->getMockBuilder(\Redis::class) + ->disableOriginalConstructor() + ->getMock(); + $redisMock->method('info')->willReturn(['redis_version' => '3.0.0']); + $redisMock->expects(self::once()) + ->method('scan') + ->with(null, 'some-namespace*', 1000, 'string') + ->willReturn([0, []]); + $mock = new class($redisMock) { + use RedisTrait { + doClear as public; + } + + public function __construct($redis) + { + $this->redis = $redis; + } + }; + + $mock->doClear('some-namespace'); + } } diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index 287c0ea962121..21460828fd030 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -476,7 +476,7 @@ protected function doClear(string $namespace) $cursor = null; do { - $keys = $host instanceof \Predis\ClientInterface ? $host->scan($cursor, 'MATCH', $pattern, 'COUNT', 1000) : $host->scan($cursor, $pattern, 1000); + $keys = $host instanceof \Predis\ClientInterface ? $host->scan($cursor, 'MATCH', $pattern, 'COUNT', 1000) : $host->scan($cursor, $pattern, 1000, 'string'); if (isset($keys[1]) && \is_array($keys[1])) { $cursor = $keys[0]; $keys = $keys[1];