diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php index ea73930c200f..a68995b05a9d 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php @@ -5,6 +5,7 @@ use Exception; use Illuminate\Foundation\Application; use Illuminate\Redis\RedisManager; +use Illuminate\Support\Env; trait InteractsWithRedis { @@ -30,8 +31,8 @@ trait InteractsWithRedis public function setUpRedis() { $app = $this->app ?? new Application; - $host = getenv('REDIS_HOST') ?: '127.0.0.1'; - $port = getenv('REDIS_PORT') ?: 6379; + $host = Env::get('REDIS_HOST', '127.0.0.1'); + $port = Env::get('REDIS_PORT', 6379); if (! extension_loaded('redis')) { $this->markTestSkipped('The redis extension is not installed. Please install the extension to enable '.__CLASS__); @@ -63,7 +64,7 @@ public function setUpRedis() try { $this->redis['phpredis']->connection()->flushdb(); } catch (Exception $e) { - if ($host === '127.0.0.1' && $port === 6379 && getenv('REDIS_HOST') === false) { + if ($host === '127.0.0.1' && $port === 6379 && Env::get('REDIS_HOST') === null) { static::$connectionFailedOnceWithDefaultsSkip = true; $this->markTestSkipped('Trying default host/port failed, please set environment variable REDIS_HOST & REDIS_PORT to enable '.__CLASS__); } diff --git a/tests/Redis/RedisConnectionTest.php b/tests/Redis/RedisConnectionTest.php index 084805cb1178..aaa4bf52ad5f 100644 --- a/tests/Redis/RedisConnectionTest.php +++ b/tests/Redis/RedisConnectionTest.php @@ -554,8 +554,8 @@ public function connections() 'phpredis' => $this->redis['phpredis']->connection(), ]; - $host = getenv('REDIS_HOST') ?: '127.0.0.1'; - $port = getenv('REDIS_PORT') ?: 6379; + $host = env('REDIS_HOST', '127.0.0.1'); + $port = env('REDIS_PORT', 6379); $prefixedPhpredis = new RedisManager(new Application, 'phpredis', [ 'cluster' => false,