Skip to content

Commit

Permalink
Skip Memcached and Redis tests when servers are not running.
Browse files Browse the repository at this point in the history
When the extensions are present but memcached or redis are not running,
tests should be skipped.

Refs #5993
  • Loading branch information
markstory committed Mar 3, 2015
1 parent acdaffc commit f53cdbf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Cache/Engine/MemcachedEngine.php
Expand Up @@ -115,7 +115,7 @@ public function init(array $config = [])
}

parent::init($config);

if (!empty($config['host'])) {
if (empty($config['port'])) {
$config['servers'] = [$config['host']];
Expand Down
6 changes: 4 additions & 2 deletions tests/TestCase/Cache/Engine/MemcachedEngineTest.php
Expand Up @@ -66,6 +66,10 @@ public function setUp()
parent::setUp();
$this->skipIf(!class_exists('Memcached'), 'Memcached is not installed or configured properly.');

$socket = @fsockopen('127.0.0.1', 11211, $errno, $errstr, 1);
$this->skipIf(!$socket, 'Memcached is not running.');
fclose($socket);

$this->_configCache();
}

Expand Down Expand Up @@ -831,8 +835,6 @@ public function testZeroDuration()
*/
public function testLongDurationEqualToZero()
{
$this->markTestSkipped('Cannot run as Memcached cannot be reflected');

$memcached = new TestMemcachedEngine();
$memcached->init(['prefix' => 'Foo_', 'compress' => false, 'duration' => 50 * DAY]);

Expand Down
6 changes: 5 additions & 1 deletion tests/TestCase/Cache/Engine/RedisEngineTest.php
Expand Up @@ -36,7 +36,11 @@ class RedisEngineTest extends TestCase
public function setUp()
{
parent::setUp();
$this->skipIf(!class_exists('Redis'), 'Redis is not installed or configured properly.');
$this->skipIf(!class_exists('Redis'), 'Redis extension is not installed or configured properly.');

$socket = @fsockopen('127.0.0.1', 6379, $errno, $errstr, 1);
$this->skipIf(!$socket, 'Redis is not running.');
fclose($socket);

Cache::enable();
$this->_configCache();
Expand Down

0 comments on commit f53cdbf

Please sign in to comment.