-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from vmpublishing/master
provide predis native configuration option
- Loading branch information
Showing
9 changed files
with
243 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
|
||
[*.{js,json,rb,erb,scss,css}] | ||
indent_size = 2 | ||
|
||
[*.{php,twig,yml}] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
# do not deploy docker testing stuff | ||
/docker export-ignore | ||
docker-compose.yml export-ignore | ||
|
||
# do not deploy git stuff | ||
.gitattributes | ||
.gitignore | ||
.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: '3' | ||
|
||
services: | ||
app_5_3: | ||
build: | ||
context: . | ||
dockerfile: 'docker/app_5_3/Dockerfile' | ||
volumes: | ||
- ".:/php-resque" | ||
working_dir: '/php-resque' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM tomsowerby/php-5.3 | ||
|
||
RUn apt-get update -yqq && apt-get upgrade -yqq | ||
|
||
RUN apt-get install -yqq git-core | ||
|
||
RUN pecl install -o -f redis && rm -rf /tmp/pear && docker-php-ext-enable redis | ||
|
||
# composer | ||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | ||
|
||
RUN docker-php-ext-install pcntl | ||
|
||
|
||
CMD composer install -v && tail -f /dev/null | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?php | ||
|
||
namespace Resque\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class RedisTest extends TestCase | ||
{ | ||
|
||
private $legacyParameters = array( | ||
'scheme' => 'tcp', | ||
'host' => 'redis_instance_01', | ||
'port' => 6379, | ||
'namespace' => 'some_namespace', | ||
'rw_timeout' => 123, | ||
'phpiredis' => true, | ||
); | ||
|
||
private $predisNativeParameters = array( | ||
'config' => array( | ||
array( | ||
'tcp://10.0.0.1', | ||
'tcp://10.0.0.2', | ||
'tcp://10.0.0.3', | ||
), | ||
), | ||
'options' => array( | ||
'replication' => 'sentinel', | ||
'service' => 'some_redis_cluster', | ||
'parameters' => array( | ||
'password' => 'some_secure_password', | ||
'database' => 10, | ||
), | ||
), | ||
); | ||
|
||
private $predisMock = null; | ||
|
||
private $redisMock = null; | ||
|
||
public function setUp() | ||
{ | ||
|
||
$predisClassName = "\\Predis\\Client"; | ||
|
||
$this->predisMock = $this->getMockBuilder($predisClassName) | ||
->disableOriginalConstructor() | ||
->setMethods(array('connect')) | ||
->getMock() | ||
; | ||
|
||
$className = "\\Resque\\Redis"; | ||
|
||
$this->redisMock = $this->getMockBuilder($className) | ||
->disableOriginalConstructor() | ||
->setMethods(array('initializePredisClient')) | ||
->getMock() | ||
; | ||
|
||
} | ||
|
||
public function tearDown() | ||
{ | ||
$this->predisMock = null; | ||
} | ||
|
||
public function testConstructorShouldDoTheLegacyStuff() | ||
{ | ||
|
||
$this->redisMock->expects($this->once()) | ||
->method('initializePredisClient') | ||
->with( | ||
array( | ||
'scheme' => $this->legacyParameters['scheme'], | ||
'host' => $this->legacyParameters['host'], | ||
'port' => $this->legacyParameters['port'], | ||
'read_write_timeout' => $this->legacyParameters['rw_timeout'], | ||
), | ||
array( | ||
'connections' => array( | ||
'tcp' => 'Predis\Connection\PhpiredisStreamConnection', | ||
'unix' => 'Predis\Connection\PhpiredisSocketConnection', | ||
), | ||
) | ||
) | ||
->willReturn($this->predisMock) | ||
; | ||
|
||
$this->predisMock->expects($this->any())->method('connect'); | ||
|
||
$this->redisMock->__construct($this->legacyParameters); | ||
} | ||
|
||
public function testConstructorShouldAcceptPredisOverride() | ||
{ | ||
$className = "\\Resque\\Redis"; | ||
|
||
$this->redisMock = $this->getMockBuilder($className) | ||
->disableOriginalConstructor() | ||
->setMethods(array('initializePredisClient')) | ||
->getMock() | ||
; | ||
|
||
$this->redisMock->expects($this->once()) | ||
->method('initializePredisClient') | ||
->with( | ||
$this->predisNativeParameters['config'], | ||
$this->predisNativeParameters['options'] | ||
) | ||
->willReturn($this->predisMock) | ||
; | ||
|
||
$this->predisMock->expects($this->any())->method('connect'); | ||
|
||
$this->redisMock->__construct(array_merge($this->legacyParameters, array('predis' => $this->predisNativeParameters))); | ||
} | ||
|
||
} |