Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix redis tests #578

Merged
merged 1 commit into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ cache:

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

install:
- rm $HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini;
Expand Down
4 changes: 4 additions & 0 deletions pkg/redis/PRedis.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class PRedis implements Redis
*/
public function __construct(array $config)
{
if (false == class_exists(Client::class)) {
throw new \LogicException('The package "predis/predis" must be installed. Please run "composer req predis/predis:^1.1" to install it');
}

$this->options = $config['predis_options'];

$this->parameters = [
Expand Down
4 changes: 4 additions & 0 deletions pkg/redis/PhpRedis.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class PhpRedis implements Redis
*/
public function __construct(array $config)
{
if (false == class_exists(\Redis::class)) {
throw new \LogicException('You must install the redis extension to use phpredis');
}

$this->config = $config;
}

Expand Down
8 changes: 0 additions & 8 deletions pkg/redis/RedisConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,8 @@ private function createRedis(): Redis
{
if (false == $this->redis) {
if (in_array('phpredis', $this->config['scheme_extensions'], true)) {
if (false == class_exists(\Redis::class)) {
throw new \LogicException('You must install the redis extension to use phpredis');
}

$this->redis = new PhpRedis($this->config);
} else {
if (false == class_exists(\Predis\Client::class)) {
throw new \LogicException('The package "predis/predis" must be installed. Please run "composer req predis/predis:^1.1" to install it');
}

$this->redis = new PRedis($this->config);
}

Expand Down