|
@@ -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 --------------------------------------------- //
|
|
|
// ******************************************************************** //
|