|
@@ -321,6 +321,44 @@ class ClientTest extends StandardTestCase
|
|
|
$this->assertTrue($client->executeCommand($ping));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @group disconnected
|
|
|
+ * @expectedException Predis\ServerException
|
|
|
+ * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
|
|
|
+ */
|
|
|
+ public function testExecuteCommandThrowsExceptionOnRedisError()
|
|
|
+ {
|
|
|
+ $ping = ServerProfile::getDefault()->createCommand('ping', array());
|
|
|
+ $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value');
|
|
|
+
|
|
|
+ $connection= $this->getMock('Predis\Connection\ConnectionInterface');
|
|
|
+ $connection->expects($this->once())
|
|
|
+ ->method('executeCommand')
|
|
|
+ ->will($this->returnValue($expectedResponse));
|
|
|
+
|
|
|
+ $client = new Client($connection);
|
|
|
+ $client->executeCommand($ping);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @group disconnected
|
|
|
+ */
|
|
|
+ public function testExecuteCommandReturnsErrorResponseOnRedisError()
|
|
|
+ {
|
|
|
+ $ping = ServerProfile::getDefault()->createCommand('ping', array());
|
|
|
+ $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value');
|
|
|
+
|
|
|
+ $connection= $this->getMock('Predis\Connection\ConnectionInterface');
|
|
|
+ $connection->expects($this->once())
|
|
|
+ ->method('executeCommand')
|
|
|
+ ->will($this->returnValue($expectedResponse));
|
|
|
+
|
|
|
+ $client = new Client($connection, array('exceptions' => false));
|
|
|
+ $response = $client->executeCommand($ping);
|
|
|
+
|
|
|
+ $this->assertSame($response, $expectedResponse);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @group disconnected
|
|
|
*/
|
|
@@ -345,6 +383,44 @@ class ClientTest extends StandardTestCase
|
|
|
$this->assertTrue($client->ping());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @group disconnected
|
|
|
+ * @expectedException Predis\ServerException
|
|
|
+ * @expectedExceptionMessage ERR Operation against a key holding the wrong kind of value
|
|
|
+ */
|
|
|
+ public function testCallingRedisCommandThrowsExceptionOnServerError()
|
|
|
+ {
|
|
|
+ $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value');
|
|
|
+
|
|
|
+ $connection = $this->getMock('Predis\Connection\ConnectionInterface');
|
|
|
+ $connection->expects($this->once())
|
|
|
+ ->method('executeCommand')
|
|
|
+ ->with($this->isInstanceOf('Predis\Command\ConnectionPing'))
|
|
|
+ ->will($this->returnValue($expectedResponse));
|
|
|
+
|
|
|
+ $client = new Client($connection);
|
|
|
+ $client->ping();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @group disconnected
|
|
|
+ */
|
|
|
+ public function testCallingRedisCommandReturnsErrorResponseOnRedisError()
|
|
|
+ {
|
|
|
+ $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value');
|
|
|
+
|
|
|
+ $connection = $this->getMock('Predis\Connection\ConnectionInterface');
|
|
|
+ $connection->expects($this->once())
|
|
|
+ ->method('executeCommand')
|
|
|
+ ->with($this->isInstanceOf('Predis\Command\ConnectionPing'))
|
|
|
+ ->will($this->returnValue($expectedResponse));
|
|
|
+
|
|
|
+ $client = new Client($connection, array('exceptions' => false));
|
|
|
+ $response = $client->ping();
|
|
|
+
|
|
|
+ $this->assertSame($response, $expectedResponse);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @group disconnected
|
|
|
* @expectedException Predis\ClientException
|