Beispiel #1
0
 function testResponseReader_OptionExceptionOnError()
 {
     $connection = new \Predis\TcpConnection(RC::getConnectionParameters());
     $responseReader = $connection->getResponseReader();
     $connection->rawCommand("SET key 5\r\nvalue\r\n");
     $rawCmdUnexpected = "LPUSH key 5\r\nvalue\r\n";
     $responseReader->setHandler(\Predis\Protocol::PREFIX_ERROR, new \Predis\ResponseErrorSilentHandler());
     $errorReply = $connection->rawCommand($rawCmdUnexpected);
     $this->assertType('\\Predis\\ResponseError', $errorReply);
     $this->assertEquals(RC::EXCEPTION_WRONG_TYPE, $errorReply->message);
     $responseReader->setHandler(\Predis\Protocol::PREFIX_ERROR, new \Predis\ResponseErrorHandler());
     RC::testForServerException($this, RC::EXCEPTION_WRONG_TYPE, function () use($connection, $rawCmdUnexpected) {
         $connection->rawCommand($rawCmdUnexpected);
     });
 }