diff --git a/src/Stash/Driver/Redis.php b/src/Stash/Driver/Redis.php index 88bd2eb9..f8371c5e 100644 --- a/src/Stash/Driver/Redis.php +++ b/src/Stash/Driver/Redis.php @@ -173,7 +173,9 @@ public function setOptions(array $options = array()) */ public function __destruct() { - $this->redis->close(); + if ($this->redis instanceof \Redis) { + $this->redis->close(); + } } /** diff --git a/tests/Stash/Test/Driver/RedisArrayTest.php b/tests/Stash/Test/Driver/RedisArrayTest.php index 8878c178..fbc7524d 100644 --- a/tests/Stash/Test/Driver/RedisArrayTest.php +++ b/tests/Stash/Test/Driver/RedisArrayTest.php @@ -24,6 +24,10 @@ class RedisArrayTest extends RedisTest protected function setUp() { + if (defined('HHVM_VERSION')) { + $this->markTestSkipped('RedisArray currently not supported by HHVM.'); + } + parent::setUp(); if (!($sock = @fsockopen($this->redisServer, $this->redisPort, $errno, $errstr, 1))) { @@ -40,9 +44,24 @@ protected function setUp() protected function getOptions() { return array( - array('server' => $this->redisServer, 'port' => $this->redisPort, 'ttl' => 0.1), - array('server' => $this->redisSecondServer, 'port' => $this->redisSecondPort, 'ttl' => 0.1), + 'servers' => array( + array('server' => $this->redisServer, 'port' => $this->redisPort, 'ttl' => 0.1), + array('server' => $this->redisSecondServer, 'port' => $this->redisSecondPort, 'ttl' => 0.1), + ), ); } + /** + * @test + */ + public function itShouldConstructARedisArray() + { + $driver = $this->getFreshDriver(); + $class = new \ReflectionClass($driver); + $redisProperty = $class->getProperty('redis'); + $redisProperty->setAccessible(true); + $redisArray = $redisProperty->getValue($driver); + + $this->assertInstanceOf('\RedisArray', $redisArray); + } }