Skip to content

Commit

Permalink
Updated beanstalk service and adapter to skip tests if server not run…
Browse files Browse the repository at this point in the history
…ning
  • Loading branch information
Mark Wilde committed Apr 24, 2014
1 parent 80716b4 commit 9579bc1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/cases/extensions/adapter/queue/BeanstalkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,32 @@
namespace li3_queue\tests\cases\extensions\adapter\queue;

use li3_queue\extensions\adapter\queue\Beanstalk;
use lithium\core\NetworkException;

class BeanstalkTest extends \lithium\test\Unit {

public $beanstalk = null;

protected $_testConfig = array(
'host' => '127.0.0.1',
'port' => 11300,
'autoConnect' => true
);

public function skip() {
$config = $this->_testConfig;

try {
$conn = new Beanstalk($config);
} catch (NetworkException $e) {
$message = "A Beanstalk server does not appear to be running on ";
$message .= $config['host'] . ':' . $config['port'];
$hasBeanstalk = ($e->getCode() != 503) ? true : false;
$this->skipIf(!$hasBeanstalk, $message);
}
unset($conn);
}

public function testInitialize() {
$beanstalk = new Beanstalk();
$this->assertInternalType('object', $beanstalk);
Expand Down
22 changes: 22 additions & 0 deletions tests/cases/net/beanstalk/ServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,33 @@
namespace li3_queue\tests\cases\net\beanstalk;

use li3_queue\net\beanstalk\Service;
use lithium\core\NetworkException;

class ServiceTest extends \lithium\test\Unit {

public $service = null;

protected $_testConfig = array(
'host' => '127.0.0.1',
'port' => 11300
);

public function skip() {
$config = $this->_testConfig;

$conn = new Service($config);

try {
$conn->connect();
} catch (NetworkException $e) {
$message = "A Beanstalk server does not appear to be running on ";
$message .= $config['host'] . ':' . $config['port'];
$hasBeanstalk = ($e->getCode() != 503) ? true : false;
$this->skipIf(!$hasBeanstalk, $message);
}
unset($conn);
}

public function testConnection() {
$service = new Service();
$result = $service->connect();
Expand Down

0 comments on commit 9579bc1

Please sign in to comment.