8000 [FrameworkBundle] Fix tests · symfony/symfony@af1b2cc · GitHub
[go: up one dir, main page]

Skip to content

Commit af1b2cc

Browse files
[FrameworkBundle] Fix tests
1 parent ba0e346 commit af1b2cc

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,15 @@ public function testCachePools()
2727
*/
2828
public function testRedisCachePools()
2929
{
30+
$this->skipIfRedisUnavailable();
31+
3032
try {
3133
$this->doTestCachePools(['root_config' => 'redis_config.yml', 'environment' => 'redis_cache'], RedisAdapter::class);
3234
} catch (\PHPUnit\Framework\Error\Warning $e) {
3335
if (0 !== strpos($e->getMessage(), 'unable to connect to')) {
3436
throw $e;
3537
}
3638 $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());
4239
} catch (InvalidArgumentException $e) {
4340
if (0 !== strpos($e->getMessage(), 'Redis connection ')) {
4441
throw $e;
@@ -52,18 +49,15 @@ public function testRedisCachePools()
5249
*/
5350
public function testRedisCustomCachePools()
5451
{
52+
$this->skipIfRedisUnavailable();
53+
5554
try {
5655
$this->doTestCachePools(['root_config' => 'redis_custom_config.yml', 'environment' => 'custom_redis_cache'], RedisAdapter::class);
5756
} catch (\PHPUnit\Framework\Error\Warning $e) {
5857
if (0 !== strpos($e->getMessage(), 'unable to connect to')) {
5958
throw $e;
6059
}
6160
$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());
6761
}
6862
}
6963

@@ -100,4 +94,13 @@ protected static function createKernel(array $options = [])
10094
{
10195
return parent::createKernel(['test_case' => 'CachePools'] + $options);
10296
}
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+
}
103106
}

0 commit comments

Comments
 (0)
0