Skip to content

Commit 011f4be

Browse files
committed
[redis] fix tests.
1 parent 6be9cb1 commit 011f4be

1 file changed

Lines changed: 20 additions & 24 deletions

File tree

RedisExtension.php

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,42 @@
22

33
namespace Enqueue\Test;
44

5+
use Enqueue\Redis\PhpRedis;
6+
use Enqueue\Redis\PRedis;
57
use Enqueue\Redis\RedisConnectionFactory;
68
use Enqueue\Redis\RedisContext;
79

810
trait RedisExtension
911
{
10-
/**
11-
* @return RedisContext
12-
*/
13-
private function buildPhpRedisContext()
12+
private function buildPhpRedisContext(): RedisContext
1413
{
15-
if (false == getenv('REDIS_HOST')) {
14+
if (false == getenv('PHPREDIS_DSN')) {
1615
throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment');
1716
}
1817

19-
$config = [
20-
'host' => getenv('REDIS_HOST'),
21-
'port' => (int) getenv('REDIS_PORT'),
22-
'vendor' => 'phpredis',
23-
'lazy' => false,
24-
];
18+
$config = getenv('PHPREDIS_DSN');
2519

26-
return (new RedisConnectionFactory($config))->createContext();
20+
$context = (new RedisConnectionFactory($config))->createContext();
21+
22+
//guard
23+
$this->assertInstanceOf(PhpRedis::class, $context->getRedis());
24+
25+
return $context;
2726
}
2827

29-
/**
30-
* @return RedisContext
31-
*/
32-
private function buildPRedisContext()
28+
private function buildPRedisContext(): RedisContext
3329
{
34-
if (false == getenv('REDIS_HOST')) {
30+
if (false == getenv('PREDIS_DSN')) {
3531
throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment');
3632
}
3733

38-
$config = [
39-
'host' => getenv('REDIS_HOST'),
40-
'port' => getenv('REDIS_PORT'),
41-
'vendor' => 'predis',
42-
'lazy' => false,
43-
];
34+
$config = getenv('PREDIS_DSN');
35+
36+
$context = (new RedisConnectionFactory($config))->createContext();
37+
38+
//guard
39+
$this->assertInstanceOf(PRedis::class, $context->getRedis());
4440

45-
return (new RedisConnectionFactory($config))->createContext();
41+
return $context;
4642
}
4743
}

0 commit comments

Comments
 (0)