@@ -27,18 +27,15 @@ public function testCachePools()
27
27
*/
28
28
public function testRedisCachePools ()
29
29
{
30
+ $ this ->skipIfRedisUnavailable ();
31
+
30
32
try {
31
33
$ this ->doTestCachePools (['root_config ' => 'redis_config.yml ' , 'environment ' => 'redis_cache ' ], RedisAdapter::class);
32
34
} catch (\PHPUnit \Framework \Error \Warning $ e ) {
33
35
if (0 !== strpos ($ e ->getMessage (), 'unable to connect to ' )) {
34
36
throw $ e ;
35
37
}
36
38
$ this ->markTestSkipped ($ e ->getMessage ());
37
- } catch (\PHPUnit \Framework \Error \Warning $ e ) {
38
- if (0 !== strpos ($ e ->getMessage (), 'unable to connect to ' )) {
39
- throw $ e ;
40
- }
41
- $ this ->markTestSkipped ($ e ->getMessage ());
42
39
} catch (InvalidArgumentException $ e ) {
43
40
if (0 !== strpos ($ e ->getMessage (), 'Redis connection ' )) {
44
41
throw $ e ;
@@ -52,18 +49,15 @@ public function testRedisCachePools()
52
49
*/
53
50
public function testRedisCustomCachePools ()
54
51
{
52
+ $ this ->skipIfRedisUnavailable ();
53
+
55
54
try {
56
55
$ this ->doTestCachePools (['root_config ' => 'redis_custom_config.yml ' , 'environment ' => 'custom_redis_cache ' ], RedisAdapter::class);
57
56
} catch (\PHPUnit \Framework \Error \Warning $ e ) {
58
57
if (0 !== strpos ($ e ->getMessage (), 'unable to connect to ' )) {
59
58
throw $ e ;
60
59
}
61
60
$ this ->markTestSkipped ($ e ->getMessage ());
62
- } catch (\PHPUnit \Framework \Error \Warning $ e ) {
63
- if (0 !== strpos ($ e ->getMessage (), 'unable to connect to ' )) {
64
- throw $ e ;
65
- }
66
- $ this ->markTestSkipped ($ e ->getMessage ());
67
61
}
68
62
}
69
63
@@ -100,4 +94,13 @@ protected static function createKernel(array $options = [])
100
94
{
101
95
return parent ::createKernel (['test_case ' => 'CachePools ' ] + $ options );
102
96
}
97
+
98
+ private function skipIfRedisUnavailable ()
99
+ {
100
+ try {
101
+ (new \Redis ())->connect (getenv ('REDIS_HOST ' ));
102
+ } catch (\Exception $ e ) {
103
+ self ::markTestSkipped ($ e ->getMessage ());
104
+ }
105
+ }
103
106
}
0 commit comments