From 604cf80edb56c20ea929aea22576e4e543bfff24 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Tue, 24 Dec 2019 18:30:51 +0000 Subject: [PATCH 1/3] Fixed code that depended on getenv --- .../Foundation/Testing/Concerns/InteractsWithRedis.php | 6 +++--- tests/Redis/RedisConnectionTest.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php index ea73930c200f..6bef935ed4f9 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php @@ -30,8 +30,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('REDIS_HOST', '127.0.0.1'); + $port = env('REDIS_PORT', 6379); if (! extension_loaded('redis')) { $this->markTestSkipped('The redis extension is not installed. Please install the extension to enable '.__CLASS__); @@ -63,7 +63,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('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, From 2949db434af89c48876c608e81436e5493ff9857 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Tue, 24 Dec 2019 19:01:49 +0000 Subject: [PATCH 2/3] Update InteractsWithRedis.php --- .../Foundation/Testing/Concerns/InteractsWithRedis.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php index 6bef935ed4f9..713058232a48 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php @@ -3,6 +3,7 @@ namespace Illuminate\Foundation\Testing\Concerns; use Exception; +use Illuminate\Support\Env; use Illuminate\Foundation\Application; use Illuminate\Redis\RedisManager; @@ -30,8 +31,8 @@ trait InteractsWithRedis public function setUpRedis() { $app = $this->app ?? new Application; - $host = env('REDIS_HOST', '127.0.0.1'); - $port = env('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 && env('REDIS_HOST') === null) { + 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__); } From 675753b8eb9b0c4a141d39fa2386495280c47f99 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Tue, 24 Dec 2019 19:02:10 +0000 Subject: [PATCH 3/3] Apply fixes from StyleCI (#30925) --- .../Foundation/Testing/Concerns/InteractsWithRedis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php index 713058232a48..a68995b05a9d 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php @@ -3,9 +3,9 @@ namespace Illuminate\Foundation\Testing\Concerns; use Exception; -use Illuminate\Support\Env; use Illuminate\Foundation\Application; use Illuminate\Redis\RedisManager; +use Illuminate\Support\Env; trait InteractsWithRedis {