[tests] Fix tests from previous commit.

They did work, but I am not exactly sure why. Also added a missing
test for Predis\Connection\CompositeStreamConnection.
This commit is contained in:
Daniele Alessandri
2016-05-17 20:06:30 +02:00
parent 26d7147646
commit d55826f35c
4 changed files with 29 additions and 3 deletions
@@ -11,6 +11,9 @@
namespace Predis\Connection;
use Predis\Command\RawCommand;
use Predis\Response\Error as ErrorResponse;
/**
*
*/
@@ -18,6 +21,32 @@ class CompositeStreamConnectionTest extends PredisConnectionTestCase
{
const CONNECTION_CLASS = 'Predis\Connection\CompositeStreamConnection';
/**
* @group disconnected
* @expectedException \Predis\Connection\ConnectionException
* @expectedExceptionMessage `SELECT` failed: ERR invalid DB index [tcp://127.0.0.1:6379]
*/
public function testThrowsExceptionOnInitializationCommandFailure()
{
$cmdSelect = RawCommand::create('SELECT', '1000');
$connection = $this->getMockBuilder(static::CONNECTION_CLASS)
->setMethods(array('executeCommand', 'createResource'))
->setConstructorArgs(array(new Parameters()))
->getMock();
$connection->method('executeCommand')
->with($cmdSelect)
->will($this->returnValue(
new ErrorResponse("ERR invalid DB index")
));
$connection->method('createResource');
$connection->addConnectCommand($cmdSelect);
$connection->connect();
}
// ******************************************************************** //
// ---- INTEGRATION TESTS --------------------------------------------- //
// ******************************************************************** //
@@ -54,7 +54,6 @@ class PhpiredisSocketConnectionTest extends PredisConnectionTestCase
public function testThrowsExceptionOnInitializationCommandFailure()
{
$cmdSelect = RawCommand::create('SELECT', '1000');
$responseError =
$connection = $this->getMockBuilder(static::CONNECTION_CLASS)
->setMethods(array('executeCommand', 'createResource'))
@@ -54,7 +54,6 @@ class PhpiredisStreamConnectionTest extends PredisConnectionTestCase
public function testThrowsExceptionOnInitializationCommandFailure()
{
$cmdSelect = RawCommand::create('SELECT', '1000');
$responseError =
$connection = $this->getMockBuilder(static::CONNECTION_CLASS)
->setMethods(array('executeCommand', 'createResource'))
@@ -29,7 +29,6 @@ class StreamConnectionTest extends PredisConnectionTestCase
public function testThrowsExceptionOnInitializationCommandFailure()
{
$cmdSelect = RawCommand::create('SELECT', '1000');
$responseError =
$connection = $this->getMockBuilder(static::CONNECTION_CLASS)
->setMethods(array('executeCommand', 'createResource'))