From baa7471cb55aac5c0c070800bfd3c590e5b07cc9 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 27 May 2016 14:28:25 +0100 Subject: [PATCH] More amqp fixes --- src/Monolog/Handler/AmqpHandler.php | 2 ++ tests/Monolog/Handler/AmqpHandlerTest.php | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Monolog/Handler/AmqpHandler.php b/src/Monolog/Handler/AmqpHandler.php index 330416ba..b46435a6 100644 --- a/src/Monolog/Handler/AmqpHandler.php +++ b/src/Monolog/Handler/AmqpHandler.php @@ -42,6 +42,8 @@ class AmqpHandler extends AbstractProcessingHandler $this->exchangeName = $exchangeName; } elseif (!$exchange instanceof AMQPExchange) { throw new \InvalidArgumentException('PhpAmqpLib\Channel\AMQPChannel or AMQPExchange instance required'); + } elseif ($exchangeName) { + @trigger_error('The $exchangeName parameter can only be passed when using PhpAmqpLib, if using an AMQPExchange instance configure it beforehand', E_USER_DEPRECATED); } $this->exchange = $exchange; diff --git a/tests/Monolog/Handler/AmqpHandlerTest.php b/tests/Monolog/Handler/AmqpHandlerTest.php index c70e1621..414e64ba 100644 --- a/tests/Monolog/Handler/AmqpHandlerTest.php +++ b/tests/Monolog/Handler/AmqpHandlerTest.php @@ -34,10 +34,6 @@ class AmqpHandlerTest extends TestCase $messages = []; $exchange = $this->getMock('AMQPExchange', ['publish', 'setName'], [], '', false); - $exchange->expects($this->once()) - ->method('setName') - ->with('log') - ; $exchange->expects($this->any()) ->method('publish') ->will($this->returnCallback(function ($message, $routing_key, $flags = 0, $attributes = []) use (&$messages) { @@ -45,7 +41,7 @@ class AmqpHandlerTest extends TestCase })) ; - $handler = new AmqpHandler($exchange, 'log'); + $handler = new AmqpHandler($exchange); $record = $this->getRecord(Logger::WARNING, 'test', ['data' => new \stdClass, 'foo' => 34]);