@@ -147,6 +147,42 @@ public function testItAllowsToUseAPersistentConnection()
147
147
$ connection = Connection::fromDsn ('amqp://localhost/%2f/messages?persistent=true ' , array (), false , $ factory );
148
148
$ connection ->publish ('body ' );
149
149
}
150
+
151
+ public function testItSetupsTheConnectionWhenDebug ()
152
+ {
153
+ $ factory = new TestAmqpFactory (
154
+ $ amqpConnection = $ this ->getMockBuilder (\AMQPConnection::class)->disableOriginalConstructor ()->getMock (),
155
+ $ amqpChannel = $ this ->getMockBuilder (\AMQPChannel::class)->disableOriginalConstructor ()->getMock (),
156
+ $ amqpQueue = $ this ->getMockBuilder (\AMQPQueue::class)->disableOriginalConstructor ()->getMock (),
157
+ $ amqpExchange = $ this ->getMockBuilder (\AMQPExchange::class)->disableOriginalConstructor ()->getMock ()
158
+ );
159
+
160
+ $ amqpExchange ->method ('getName ' )->willReturn ('exchange_name ' );
161
+ $ amqpExchange ->expects ($ this ->once ())->method ('declareExchange ' );
162
+ $ amqpQueue ->expects ($ this ->once ())->method ('declareQueue ' );
163
+ $ amqpQueue ->expects ($ this ->once ())->method ('bind ' )->with ('exchange_name ' , 'my_key ' );
164
+
165
+ $ connection = Connection::fromDsn ('amqp://localhost/%2f/messages?queue[routing_key]=my_key ' , array (), true , $ factory );
166
+ $ connection ->publish ('body ' );
167
+ }
168
+
169
+ public function testItCanDisableTheSetup ()
170
+ {
171
+ $ factory = new TestAmqpFactory (
172
+ $ amqpConnection = $ this ->getMockBuilder (\AMQPConnection::class)->disableOriginalConstructor ()->getMock (),
173
+ $ amqpChannel = $ this ->getMockBuilder (\AMQPChannel::class)->disableOriginalConstructor ()->getMock (),
174
+ $ amqpQueue = $ this ->getMockBuilder (\AMQPQueue::class)->disableOriginalConstructor ()->getMock (),
175
+ $ amqpExchange = $ this ->getMockBuilder (\AMQPExchange::class)->disableOriginalConstructor ()->getMock ()
176
+ );
177
+
178
+ $ amqpExchange ->method ('getName ' )->willReturn ('exchange_name ' );
179
+ $ amqpExchange ->expects ($ this ->never ())->method ('declareExchange ' );
180
+ $ amqpQueue ->expects ($ this ->never ())->method ('declareQueue ' );
181
+ $ amqpQueue ->expects ($ this ->never ())->method ('bind ' );
182
+
183
+ $ connection = Connection::fromDsn ('amqp://localhost/%2f/messages?queue[routing_key]=my_key ' , array ('auto-setup ' => 'false ' ), true , $ factory );
184
+ $ connection ->publish ('body ' );
185
+ }
150
186
}
151
187
152
188
class TestAmqpFactory extends AmqpFactory
0 commit comments