Skip to content

Commit b63dcc8

Browse files
committed
fix redis tests
1 parent ff65828 commit b63dcc8

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ cache:
4242

4343
before_install:
4444
- echo "extension = mongodb.so" >> $HOME/.phpenv/versions/$(phpenv version-name)/etc/php.ini
45+
- echo "extension = redis.so" >> $HOME/.phpenv/versions/$(phpenv version-name)/etc/php.ini
4546

4647
install:
4748
- rm $HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini;

pkg/redis/PRedis.php

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class PRedis implements Redis
3030
*/
3131
public function __construct(array $config)
3232
{
33+
if (false == class_exists(Client::class)) {
34+
throw new \LogicException('The package "predis/predis" must be installed. Please run "composer req predis/predis:^1.1" to install it');
35+
}
36+
3337
$this->options = $config['predis_options'];
3438

3539
$this->parameters = [

pkg/redis/PhpRedis.php

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ class PhpRedis implements Redis
1919
*/
2020
public function __construct(array $config)
2121
{
22+
if (false == class_exists(\Redis::class)) {
23+
throw new \LogicException('You must install the redis extension to use phpredis');
24+
}
25+
2226
$this->config = $config;
2327
}
2428

pkg/redis/RedisConnectionFactory.php

-8
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,8 @@ private function createRedis(): Redis
9595
{
9696
if (false == $this->redis) {
9797
if (in_array('phpredis', $this->config['scheme_extensions'], true)) {
98-
if (false == class_exists(\Redis::class)) {
99-
throw new \LogicException('You must install the redis extension to use phpredis');
100-
}
101-
10298
$this->redis = new PhpRedis($this->config);
10399
} else {
104-
if (false == class_exists(\Predis\Client::class)) {
105-
throw new \LogicException('The package "predis/predis" must be installed. Please run "composer req predis/predis:^1.1" to install it');
106-
}
107-
108100
$this->redis = new PRedis($this->config);
109101
}
110102

0 commit comments

Comments
 (0)