mirror of
https://github.com/predis/predis.git
synced 2026-09-14 04:17:14 +00:00
[tests] Move utility method into base test class.
This commit is contained in:
@@ -203,6 +203,32 @@ abstract class PredisTestCase extends \PHPUnit_Framework_TestCase
|
||||
return $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a base mocked connection from Predis\Connection\NodeConnectionInterface.
|
||||
*
|
||||
* @param mixed $parameters Optional parameters.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getMockConnection($parameters = null)
|
||||
{
|
||||
$connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
|
||||
|
||||
if ($parameters) {
|
||||
$parameters = Connection\Parameters::create($parameters);
|
||||
$hash = "{$parameters->host}:{$parameters->port}";
|
||||
|
||||
$connection->expects($this->any())
|
||||
->method('getParameters')
|
||||
->will($this->returnValue($parameters));
|
||||
$connection->expects($this->any())
|
||||
->method('__toString')
|
||||
->will($this->returnValue($hash));
|
||||
}
|
||||
|
||||
return $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server version of the Redis instance used by the test suite.
|
||||
*
|
||||
|
||||
@@ -892,30 +892,4 @@ class ClientTest extends PredisTestCase
|
||||
|
||||
return $uriString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a base mocked connection from Predis\Connection\NodeConnectionInterface.
|
||||
*
|
||||
* @param mixed $parameters Optional parameters.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getMockConnection($parameters = null)
|
||||
{
|
||||
$connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
|
||||
|
||||
if ($parameters) {
|
||||
$parameters = \Predis\Connection\Parameters::create($parameters);
|
||||
$hash = "{$parameters->host}:{$parameters->port}";
|
||||
|
||||
$connection->expects($this->any())
|
||||
->method('getParameters')
|
||||
->will($this->returnValue($parameters));
|
||||
$connection->expects($this->any())
|
||||
->method('__toString')
|
||||
->will($this->returnValue($hash));
|
||||
}
|
||||
|
||||
return $connection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1170,34 +1170,4 @@ repl_backlog_histlen:12978
|
||||
$this->assertEquals($master, $unserialized->getConnectionById('master'));
|
||||
$this->assertEquals($slave1, $unserialized->getConnectionById('slave1'));
|
||||
}
|
||||
|
||||
// ******************************************************************** //
|
||||
// ---- HELPER METHODS ------------------------------------------------ //
|
||||
// ******************************************************************** //
|
||||
|
||||
/**
|
||||
* Returns a base mocked connection from Predis\Connection\NodeConnectionInterface.
|
||||
*
|
||||
* @param mixed $parameters Optional parameters.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getMockConnection($parameters = null)
|
||||
{
|
||||
$connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
|
||||
|
||||
if ($parameters) {
|
||||
$parameters = Connection\Parameters::create($parameters);
|
||||
$hash = "{$parameters->host}:{$parameters->port}";
|
||||
|
||||
$connection->expects($this->any())
|
||||
->method('getParameters')
|
||||
->will($this->returnValue($parameters));
|
||||
$connection->expects($this->any())
|
||||
->method('__toString')
|
||||
->will($this->returnValue($hash));
|
||||
}
|
||||
|
||||
return $connection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,34 +397,4 @@ class PredisClusterTest extends PredisTestCase
|
||||
|
||||
$this->assertEquals($cluster, $unserialized);
|
||||
}
|
||||
|
||||
// ******************************************************************** //
|
||||
// ---- HELPER METHODS ------------------------------------------------ //
|
||||
// ******************************************************************** //
|
||||
|
||||
/**
|
||||
* Returns a base mocked connection from Predis\Connection\NodeConnectionInterface.
|
||||
*
|
||||
* @param mixed $parameters Optional parameters.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getMockConnection($parameters = null)
|
||||
{
|
||||
$connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
|
||||
|
||||
if ($parameters) {
|
||||
$parameters = Connection\Parameters::create($parameters);
|
||||
$hash = "{$parameters->host}:{$parameters->port}";
|
||||
|
||||
$connection->expects($this->any())
|
||||
->method('getParameters')
|
||||
->will($this->returnValue($parameters));
|
||||
$connection->expects($this->any())
|
||||
->method('__toString')
|
||||
->will($this->returnValue($hash));
|
||||
}
|
||||
|
||||
return $connection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1157,34 +1157,4 @@ class RedisClusterTest extends PredisTestCase
|
||||
|
||||
$this->assertEquals($cluster, $unserialized);
|
||||
}
|
||||
|
||||
// ******************************************************************** //
|
||||
// ---- HELPER METHODS ------------------------------------------------ //
|
||||
// ******************************************************************** //
|
||||
|
||||
/**
|
||||
* Returns a base mocked connection from Predis\Connection\NodeConnectionInterface.
|
||||
*
|
||||
* @param mixed $parameters Optional parameters.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getMockConnection($parameters = null)
|
||||
{
|
||||
$connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
|
||||
|
||||
if ($parameters) {
|
||||
$parameters = Connection\Parameters::create($parameters);
|
||||
$hash = "{$parameters->host}:{$parameters->port}";
|
||||
|
||||
$connection->expects($this->any())
|
||||
->method('getParameters')
|
||||
->will($this->returnValue($parameters));
|
||||
$connection->expects($this->any())
|
||||
->method('__toString')
|
||||
->will($this->returnValue($hash));
|
||||
}
|
||||
|
||||
return $connection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1216,30 +1216,4 @@ class SentinelReplicationTest extends PredisTestCase
|
||||
|
||||
return $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a base mocked connection from Predis\Connection\NodeConnectionInterface.
|
||||
*
|
||||
* @param mixed $parameters Optional parameters.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getMockConnection($parameters = null)
|
||||
{
|
||||
$connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
|
||||
|
||||
if ($parameters) {
|
||||
$parameters = Connection\Parameters::create($parameters);
|
||||
$hash = "{$parameters->host}:{$parameters->port}";
|
||||
|
||||
$connection->expects($this->any())
|
||||
->method('getParameters')
|
||||
->will($this->returnValue($parameters));
|
||||
$connection->expects($this->any())
|
||||
->method('__toString')
|
||||
->will($this->returnValue($hash));
|
||||
}
|
||||
|
||||
return $connection;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user