mirror of
https://github.com/idanoo/php-resque
synced 2025-07-01 05:32:20 +00:00
Test for 'false' database value when not found in DSN
This commit is contained in:
parent
1abbad3f5e
commit
d1d2b3b354
2 changed files with 21 additions and 13 deletions
|
@ -109,7 +109,8 @@ class Resque_Redis
|
|||
|
||||
/**
|
||||
* @param string|array $server A DSN or array
|
||||
* @param int $database A database number to select
|
||||
* @param int $database A database number to select. However, if we find a valid database number in the DSN the
|
||||
* DSN-supplied value will be used instead and this parameter is ignored.
|
||||
*/
|
||||
public function __construct($server, $database = null)
|
||||
{
|
||||
|
@ -134,7 +135,7 @@ class Resque_Redis
|
|||
}
|
||||
|
||||
// If we have found a database in our DSN, use it instead of the `$database`
|
||||
// value passed into the constructor
|
||||
// value passed into the constructor.
|
||||
if ($dsnDatabase !== false) {
|
||||
$database = $dsnDatabase;
|
||||
$this->database = $database;
|
||||
|
|
|
@ -21,21 +21,21 @@ class Resque_Tests_DsnTest extends Resque_Tests_TestCase
|
|||
array('', array(
|
||||
'localhost',
|
||||
Resque_Redis::DEFAULT_PORT,
|
||||
Resque_Redis::DEFAULT_DATABASE,
|
||||
false,
|
||||
false, false,
|
||||
array(),
|
||||
)),
|
||||
array('localhost', array(
|
||||
'localhost',
|
||||
Resque_Redis::DEFAULT_PORT,
|
||||
Resque_Redis::DEFAULT_DATABASE,
|
||||
false,
|
||||
false, false,
|
||||
array(),
|
||||
)),
|
||||
array('localhost:1234', array(
|
||||
'localhost',
|
||||
1234,
|
||||
Resque_Redis::DEFAULT_DATABASE,
|
||||
false,
|
||||
false, false,
|
||||
array(),
|
||||
)),
|
||||
|
@ -49,14 +49,14 @@ class Resque_Tests_DsnTest extends Resque_Tests_TestCase
|
|||
array('redis://foobar', array(
|
||||
'foobar',
|
||||
Resque_Redis::DEFAULT_PORT,
|
||||
Resque_Redis::DEFAULT_DATABASE,
|
||||
false,
|
||||
false, false,
|
||||
array(),
|
||||
)),
|
||||
array('redis://foobar:1234', array(
|
||||
'foobar',
|
||||
1234,
|
||||
Resque_Redis::DEFAULT_DATABASE,
|
||||
false,
|
||||
false, false,
|
||||
array(),
|
||||
)),
|
||||
|
@ -67,10 +67,17 @@ class Resque_Tests_DsnTest extends Resque_Tests_TestCase
|
|||
false, false,
|
||||
array(),
|
||||
)),
|
||||
array('redis://foobar:1234/0', array(
|
||||
'foobar',
|
||||
1234,
|
||||
0,
|
||||
false, false,
|
||||
array(),
|
||||
)),
|
||||
array('redis://user@foobar:1234', array(
|
||||
'foobar',
|
||||
1234,
|
||||
Resque_Redis::DEFAULT_DATABASE,
|
||||
false,
|
||||
'user', false,
|
||||
array(),
|
||||
)),
|
||||
|
@ -84,35 +91,35 @@ class Resque_Tests_DsnTest extends Resque_Tests_TestCase
|
|||
array('redis://user:pass@foobar:1234', array(
|
||||
'foobar',
|
||||
1234,
|
||||
Resque_Redis::DEFAULT_DATABASE,
|
||||
false,
|
||||
'user', 'pass',
|
||||
array(),
|
||||
)),
|
||||
array('redis://user:pass@foobar:1234?x=y&a=b', array(
|
||||
'foobar',
|
||||
1234,
|
||||
Resque_Redis::DEFAULT_DATABASE,
|
||||
false,
|
||||
'user', 'pass',
|
||||
array('x' => 'y', 'a' => 'b'),
|
||||
)),
|
||||
array('redis://:pass@foobar:1234?x=y&a=b', array(
|
||||
'foobar',
|
||||
1234,
|
||||
Resque_Redis::DEFAULT_DATABASE,
|
||||
false,
|
||||
false, 'pass',
|
||||
array('x' => 'y', 'a' => 'b'),
|
||||
)),
|
||||
array('redis://user@foobar:1234?x=y&a=b', array(
|
||||
'foobar',
|
||||
1234,
|
||||
Resque_Redis::DEFAULT_DATABASE,
|
||||
false,
|
||||
'user', false,
|
||||
array('x' => 'y', 'a' => 'b'),
|
||||
)),
|
||||
array('redis://foobar:1234?x=y&a=b', array(
|
||||
'foobar',
|
||||
1234,
|
||||
Resque_Redis::DEFAULT_DATABASE,
|
||||
false,
|
||||
false, false,
|
||||
array('x' => 'y', 'a' => 'b'),
|
||||
)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue