@@ -31,30 +31,33 @@ public function createCachePool($defaultLifetime = 0)
31
31
return $ adapter ;
32
32
}
33
33
34
- public function testCreateConnection ()
34
+ /**
35
+ * @dataProvider provideValidSchemes
36
+ */
37
+ public function testCreateConnection ($ dsnScheme )
35
38
{
36
- $ redis = RedisAdapter::createConnection (' redis :?host[h1]&host[h2]&host[/foo:] ' );
39
+ $ redis = RedisAdapter::createConnection ($ dsnScheme . ' :?host[h1]&host[h2]&host[/foo:] ' );
37
40
$ this ->assertInstanceOf (\RedisArray::class, $ redis );
38
41
$ this ->assertSame (['h1:6379 ' , 'h2:6379 ' , '/foo ' ], $ redis ->_hosts ());
39
42
@$ redis = null ; // some versions of phpredis connect on destruct, let's silence the warning
40
43
41
44
$ redisHost = getenv ('REDIS_HOST ' );
42
45
43
- $ redis = RedisAdapter::createConnection (' redis :// ' .$ redisHost );
46
+ $ redis = RedisAdapter::createConnection ($ dsnScheme . ' :// ' .$ redisHost );
44
47
$ this ->assertInstanceOf (\Redis::class, $ redis );
45
48
$ this ->assertTrue ($ redis ->isConnected ());
46
49
$ this ->assertSame (0 , $ redis ->getDbNum ());
47
50
48
- $ redis = RedisAdapter::createConnection (' redis :// ' .$ redisHost .'/2 ' );
51
+ $ redis = RedisAdapter::createConnection ($ dsnScheme . ' :// ' .$ redisHost .'/2 ' );
49
52
$ this ->assertSame (2 , $ redis ->getDbNum ());
50
53
51
- $ redis = RedisAdapter::createConnection (' redis :// ' .$ redisHost , ['timeout ' => 3 ]);
54
+ $ redis = RedisAdapter::createConnection ($ dsnScheme . ' :// ' .$ redisHost , ['timeout ' => 3 ]);
52
55
$ this ->assertEquals (3 , $ redis ->getTimeout ());
53
56
54
- $ redis = RedisAdapter::createConnection (' redis :// ' .$ redisHost .'?timeout=4 ' );
57
+ $ redis = RedisAdapter::createConnection ($ dsnScheme . ' :// ' .$ redisHost .'?timeout=4 ' );
55
58
$ this ->assertEquals (4 , $ redis ->getTimeout ());
56
59
57
- $ redis = RedisAdapter::createConnection (' redis :// ' .$ redisHost , ['read_timeout ' => 5 ]);
60
+ $ redis = RedisAdapter::createConnection ($ dsnScheme . ' :// ' .$ redisHost , ['read_timeout ' => 5 ]);
58
61
$ this ->assertEquals (5 , $ redis ->getReadTimeout ());
59
62
}
60
63
@@ -87,6 +90,14 @@ public function testInvalidCreateConnection($dsn)
87
90
RedisAdapter::createConnection ($ dsn );
88
91
}
89
92
93
+ public function provideValidSchemes ()
94
+ {
95
+ return [
96
+ ['redis ' ],
97
+ ['rediss ' ],
98
+ ];
99
+ }
100
+
90
101
public function provideInvalidCreateConnection ()
91
102
{
92
103
return [
0 commit comments