Enable redis server in travis for testing

This commit is contained in:
Daniel Mason 2018-05-25 19:53:55 +12:00
parent bc39882dd7
commit c862009505
6 changed files with 1541 additions and 11 deletions

View File

@ -1,10 +1,14 @@
language: php language: php
php: php:
- 7.0 - 7.0
- 7.1 - 7.1
- 7.2 - 7.2
- hhvm - hhvm
services:
- redis-server
before_script: before_script:
- echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- composer install - composer install

View File

@ -14,11 +14,11 @@
"require": { "require": {
"php": ">=7.0.0", "php": ">=7.0.0",
"ext-pcntl": "*", "ext-pcntl": "*",
"ext-redis": "Native PHP extension for Redis connectivity*",
"psr/log": "~1.0" "psr/log": "~1.0"
}, },
"suggest": { "suggest": {
"ext-proctitle": "Allows php-resque to rename the title of UNIX processes to show the status of a worker.", "ext-proctitle": "Allows php-resque to rename the title of UNIX processes to show the status of a worker."
"ext-redis": "Native PHP extension for Redis connectivity. Credis will automatically utilize when available."
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^6" "phpunit/phpunit": "^6"

1526
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -124,7 +124,7 @@ class Resque_Redis
$timeout = isset($options['timeout']) ? intval($options['timeout']) : null; $timeout = isset($options['timeout']) ? intval($options['timeout']) : null;
$this->redisConnection = new \Redis(); $this->redisConnection = new Redis();
if (!$this->redisConnection->connect($host, $port, $timeout)) { if (!$this->redisConnection->connect($host, $port, $timeout)) {
throw new RedisException("Connection Failed to Redis!"); throw new RedisException("Connection Failed to Redis!");

View File

@ -323,11 +323,11 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
public function testDequeueItemWithArg() public function testDequeueItemWithArg()
{ {
$queue = 'jobs'; $queue = 'jobs';
$arg = array('foo' => 1, 'bar' => 2); $arg = ['foo' => 1, 'bar' => 2];
Resque::enqueue($queue, 'Test_Job_Dequeue9'); Resque::enqueue($queue, 'Test_Job_Dequeue9');
Resque::enqueue($queue, 'Test_Job_Dequeue9', $arg); Resque::enqueue($queue, 'Test_Job_Dequeue9', $arg);
$this->assertEquals(Resque::size($queue), 2); $this->assertEquals(Resque::size($queue), 2);
$test = array('Test_Job_Dequeue9' => $arg); $test = ['Test_Job_Dequeue9' => $arg];
$this->assertEquals(Resque::dequeue($queue, $test), 1); $this->assertEquals(Resque::dequeue($queue, $test), 1);
#$this->assertEquals(Resque::size($queue), 1); #$this->assertEquals(Resque::size($queue), 1);
} }
@ -336,16 +336,16 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
{ {
// GIVEN // GIVEN
$queue = 'jobs'; $queue = 'jobs';
$args = array('foo' => 1, 'bar' => 10); $args = ['foo' => 1, 'bar' => 10];
$removeArgs = array('foo' => 1, 'bar' => 2); $removeArgs = ['foo' => 1, 'bar' => 2];
Resque::enqueue($queue, 'Test_Job_Dequeue9', $args); Resque::enqueue($queue, 'Test_Job_Dequeue9', $args);
Resque::enqueue($queue, 'Test_Job_Dequeue9', $removeArgs); Resque::enqueue($queue, 'Test_Job_Dequeue9', $removeArgs);
Resque::enqueue($queue, 'Test_Job_Dequeue9', $removeArgs); Resque::enqueue($queue, 'Test_Job_Dequeue9', $removeArgs);
$this->assertEquals(Resque::size($queue), 3); $this->assertEquals(Resque::size($queue), 3, "Failed to add 3 items.");
// WHEN // WHEN
$test = array('Test_Job_Dequeue9' => $removeArgs); $test = ['Test_Job_Dequeue9' => $removeArgs];
$removedItems = Resque::dequeue($queue, $test); $removedItems = Resque::dequeue($queue, $test, "Dequeue one failed!");
// THEN // THEN
$this->assertEquals($removedItems, 2); $this->assertEquals($removedItems, 2);

View File

@ -22,7 +22,7 @@ class Resque_Tests_TestCase extends PHPUnit\Framework\TestCase
{ {
// $config = file_get_contents(REDIS_CONF); // $config = file_get_contents(REDIS_CONF);
// preg_match('#^\s*port\s+([0-9]+)#m', $config, $matches); // preg_match('#^\s*port\s+([0-9]+)#m', $config, $matches);
$this->redis = new \Redis(); $this->redis = new Redis();
$this->redis->connect('localhost'); $this->redis->connect('localhost');
$this->redis->select(9); $this->redis->select(9);