Skip to content

Commit 7403d51

Browse files
committed
- predis should not be installed if user want to use predis.
- Update tests - Add a gitignore for composer and vendor dir - fix deprecated autoload during tests.
1 parent f9e97d8 commit 7403d51

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
composer.lock
2+
composer.phar
3+
vendor

Tests/Doctrine/Cache/RedisCacheTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,18 @@ class RedisCacheTest extends CacheTest
2020

2121
public function setUp()
2222
{
23+
$config = 'tcp://127.0.0.1:6379';
24+
2325
if (class_exists('\Predis\Client')) {
24-
$config = 'tcp://127.0.0.1:6379';
2526
$this->_redis = new \Predis\Client($config);
27+
} elseif (class_exists('\Redis')) {
28+
$this->_redis = new \Redis();
29+
$this->_redis->connect($config);
30+
} else {
31+
$this->markTestSkipped(sprintf('The %s requires the predis library or phpredis extension.', __CLASS__));
32+
}
33+
34+
if (null !== $this->_redis) {
2635
try {
2736
$ok = $this->_redis->ping();
2837
} catch (\Exception $e) {
@@ -31,15 +40,14 @@ public function setUp()
3140
if (!$ok) {
3241
$this->markTestSkipped(sprintf('The %s requires a redis instance listening on %s.', __CLASS__, $config));
3342
}
34-
} else {
35-
$this->markTestSkipped(sprintf('The %s requires the predis library.', __CLASS__));
3643
}
3744
}
3845

3946
protected function _getCacheDriver()
4047
{
4148
$driver = new RedisCache();
4249
$driver->setRedis($this->_redis);
50+
4351
return $driver;
4452
}
4553
}

Tests/autoload.php.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

33
$vendorDir = __DIR__ . '/../vendor';
4-
$loader = require $vendorDir . '/.composer/autoload.php';
4+
$loader = require $vendorDir . '/autoload.php';
55
$loader->add('Doctrine\\Tests', $vendorDir . '/doctrine/common/tests');

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
"symfony/config": "2.0.*",
1818
"symfony/dependency-injection": "2.0.*",
1919
"symfony/framework-bundle": "2.0.*",
20-
"symfony/yaml": "2.0.*",
21-
"predis/predis": "0.7.*"
20+
"symfony/yaml": "2.0.*"
2221
},
2322
"require-dev": {
24-
"doctrine/common": "2.1.*"
23+
"doctrine/common": "2.1.*",
24+
"predis/predis": "0.7.*"
2525
},
2626
"suggest": {
27-
"monolog/monolog": "If you want to use the monolog redis handler."
27+
"monolog/monolog": "If you want to use the monolog redis handler.",
28+
"predis/predis": "If you want to use predis"
2829
},
2930
"autoload": {
3031
"psr-0": { "Snc\\RedisBundle": "" }

0 commit comments

Comments
 (0)