/** * @dataProvider consumeProvider */ public function testConsume($args, $libArgs) { $adapterChannel = $this->prophesize(AMQPChannel::class); $channel = $this->prophesize(Channel::class); $options = $this->getDefaultOptionsProphet(); $libMessage = $this->prophesize(AMQPMessage::class); $messageMapper = $this->prophesize(MessageMapper::class); $adapterChannel->basic_consume('queueName', $libArgs[3], $libArgs[0], $libArgs[1], $libArgs[2], false, Argument::type(ConsumerCallback::class))->shouldBeCalled()->willReturn($libMessage->reveal()); $adapterChannel->callbacks = ['foo', 'bar']; $adapterChannel->wait()->shouldBeCalledTimes(count($adapterChannel->callbacks))->will(function () use($adapterChannel) { $callbacks = $adapterChannel->callbacks; array_shift($callbacks); $adapterChannel->callbacks = $callbacks; }); $channel->getResource()->willReturn($adapterChannel->reveal()); $queue = new Queue(); $queue->setOptions($options->reveal()); $queue->setChannel($channel->reveal()); $queue->setMessageMapper($messageMapper->reveal()); $callback = function () { }; $ret = $queue->consume($callback, $args[0], $args[1], $args[2], $args[3]); static::assertSame($queue, $ret); }