diff --git a/src/Illuminate/Redis/Connections/PhpRedisClusterConnection.php b/src/Illuminate/Redis/Connections/PhpRedisClusterConnection.php index 7a9d2d0abc62..bf4816a4306e 100644 --- a/src/Illuminate/Redis/Connections/PhpRedisClusterConnection.php +++ b/src/Illuminate/Redis/Connections/PhpRedisClusterConnection.php @@ -13,7 +13,7 @@ public function flushdb() { $arguments = func_get_args(); - $async = strtoupper((string) $arguments[0] ?? null) === 'ASYNC'; + $async = strtoupper((string) ($arguments[0] ?? null)) === 'ASYNC'; foreach ($this->client->_masters() as $master) { $async diff --git a/src/Illuminate/Redis/Connections/PhpRedisConnection.php b/src/Illuminate/Redis/Connections/PhpRedisConnection.php index acf586bf6bdc..4e68547de3d0 100644 --- a/src/Illuminate/Redis/Connections/PhpRedisConnection.php +++ b/src/Illuminate/Redis/Connections/PhpRedisConnection.php @@ -500,7 +500,7 @@ public function flushdb() { $arguments = func_get_args(); - if (strtoupper((string) $arguments[0] ?? null) === 'ASYNC') { + if (strtoupper((string) ($arguments[0] ?? null)) === 'ASYNC') { return $this->command('flushdb', [true]); } diff --git a/tests/Redis/RedisConnectionTest.php b/tests/Redis/RedisConnectionTest.php index ea0667d8efe0..a89ebd2d4fc4 100644 --- a/tests/Redis/RedisConnectionTest.php +++ b/tests/Redis/RedisConnectionTest.php @@ -467,6 +467,28 @@ public function testItGetsMultipleKeys() } } + public function testItFlushes() + { + foreach ($this->connections() as $redis) { + $redis->set('name', 'Till'); + $this->assertSame(1, $redis->exists('name')); + + $redis->flushdb(); + $this->assertSame(0, $redis->exists('name')); + } + } + + public function testItFlushesAsynchronous() + { + foreach ($this->connections() as $redis) { + $redis->set('name', 'Till'); + $this->assertSame(1, $redis->exists('name')); + + $redis->flushdb('ASYNC'); + $this->assertSame(0, $redis->exists('name')); + } + } + public function testItRunsEval() { foreach ($this->connections() as $redis) {