Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Fixed code that depended on getenv #30924

Merged
merged 3 commits into from Dec 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -5,6 +5,7 @@
use Exception;
use Illuminate\Foundation\Application;
use Illuminate\Redis\RedisManager;
use Illuminate\Support\Env;

trait InteractsWithRedis
{
Expand All @@ -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__);
Expand Down Expand Up @@ -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__);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Redis/RedisConnectionTest.php
Expand Up @@ -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,
Expand Down