[tests] Move utility method into base test class.

This commit is contained in:
Daniele Alessandri
2016-06-01 22:27:36 +02:00
parent e386f5c732
commit 843ad23ea7
6 changed files with 26 additions and 142 deletions
+26
View File
@@ -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.
*
-26
View File
@@ -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;
}
}