Skip to content

Commit

Permalink
Merge pull request #171 from Jimdo/fix_redisarray_test_setup
Browse files Browse the repository at this point in the history
Fix RedisArray test setup
  • Loading branch information
tedivm committed May 31, 2014
2 parents 747b180 + eaa1eb7 commit 3c7dcb2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Stash/Driver/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ public function setOptions(array $options = array())
*/
public function __destruct()
{
$this->redis->close();
if ($this->redis instanceof \Redis) {
$this->redis->close();
}
}

/**
Expand Down
23 changes: 21 additions & 2 deletions tests/Stash/Test/Driver/RedisArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand All @@ -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);
}
}

0 comments on commit 3c7dcb2

Please sign in to comment.