File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414
1515use Phpfastcache \CacheManager ;
1616use Phpfastcache \Exceptions \PhpfastcacheDriverCheckException ;
17+ use Phpfastcache \Exceptions \PhpfastcacheDriverConnectException ;
1718use Phpfastcache \Tests \Helper \TestHelper ;
1819use Phpfastcache \Drivers \Predis \Config as PredisConfig ;
1920use Predis \Client as PredisClient ;
21+ use Predis \Connection \ConnectionException as PredisConnectionException ;
2022
2123chdir (__DIR__ );
2224require_once __DIR__ . '/../vendor/autoload.php ' ;
2830 }
2931
3032 $ testHelper ->mutePhpNotices ();
31- $ predisClient = new PredisClient ([
32- 'host ' => '127.0.0.1 ' ,
33- 'port ' => 6379 ,
34- 'password ' => null ,
35- 'database ' => 0 ,
36- ]);
37- $ predisClient ->connect ();
33+
34+ try {
35+ $ predisClient = new PredisClient ([
36+ 'host ' => '127.0.0.1 ' ,
37+ 'port ' => 6379 ,
38+ 'password ' => null ,
39+ 'database ' => 0 ,
40+ ]);
41+ $ predisClient ->connect ();
42+ }catch (PredisConnectionException $ e ){
43+ throw new PhpfastcacheDriverConnectException ('Redis server unreachable. ' );
44+ }
3845
3946 $ cacheInstance = CacheManager::getInstance ('Predis ' , (new PredisConfig ())->setPredisClient ($ predisClient ));
4047 $ testHelper ->runCRUDTests ($ cacheInstance );
Original file line number Diff line number Diff line change 1414
1515use Phpfastcache \CacheManager ;
1616use Phpfastcache \Exceptions \PhpfastcacheDriverCheckException ;
17+ use Phpfastcache \Exceptions \PhpfastcacheDriverConnectException ;
1718use Phpfastcache \Tests \Helper \TestHelper ;
1819use Phpfastcache \Drivers \Redis \Config as RedisConfig ;
1920use Redis as RedisClient ;
2627 if (!class_exists (RedisClient::class)) {
2728 throw new PhpfastcacheDriverCheckException ('Unable to test Redis client because the extension seems to be missing ' );
2829 }
29- $ redisClient = new RedisClient ();
30- $ redisClient ->connect ('127.0.0.1 ' , 6379 , 5 );
30+ try {
31+ $ redisClient = new RedisClient ();
32+ $ redisClient ->connect ('127.0.0.1 ' , 6379 , 5 );
33+ }catch (\RedisException $ e ){
34+ throw new PhpfastcacheDriverConnectException ('Redis server unreachable. ' );
35+ }
36+
3137 $ redisClient ->select (0 );
3238 $ cacheInstance = CacheManager::getInstance ('Redis ' , (new RedisConfig ())->setRedisClient ($ redisClient ));
3339 $ testHelper ->runCRUDTests ($ cacheInstance );
You can’t perform that action at this time.
0 commit comments