expect('AMQPQueue')->toReceive('setFlags')->with(AMQP_DURABLE); $this->queue_builder->get(); }); it('performs the declaration', function () { expect('AMQPQueue')->toReceive('declareQueue'); $this->queue_builder->get(); }); }); context('Binding', function () { it('binds with the exchange name', function () { expect('AMQPQueue')->toReceive('bind')->with($this->exchange_name, Arg::toBeAny()); $this->queue_builder->get(); }); it('binds with the binding keys', function () { foreach ($this->binding_keys as $binding_key) { expect('AMQPQueue')->toReceive('bind')->with(Arg::toBeAny(), $binding_key); } $this->queue_builder->get(); }); }); context('Exceptional behavior', function () { beforeEach(function () { $this->expectInvalidPropertyException = function () { expect(function () { $this->queue_builder->get(); })->toThrow(new InvalidPropertyException()); }; }); it("throws an exception when a name hasn't been set", function () { $this->queue_builder->setName(null); $this->expectInvalidPropertyException();
Stub::on($this->subscriber)->method('getBindingKeys'); $this->expectImplementationException(); }); it('throws an exception when batch count is an empty value', function () { Stub::on($this->subscriber)->method('getBatchCount'); $this->expectImplementationException(); }); it('throws an exception when batch count is non-integer value', function () { Stub::on($this->subscriber)->method('getBatchCount', function () { return 'asdf'; }); $this->expectImplementationException(); }); }); it('sets processMessage as the callback', function () { expect($this->amqp_queue_spy)->toReceive('consume')->with([$this->subscriber, 'processMessage']); $this->subscriber->consume(); }); }); describe('->acknowledgeMessage', function () { it("calls ack on the queue, passing in the message's delivery tag", function () { $expected_delivery_tag = 'some_delivery_tag'; $message_spy = Helper::getAMQPEnvelope(); Stub::on($message_spy)->method('getDeliveryTag')->andReturn($expected_delivery_tag); Stub::on($this->amqp_queue_spy)->method('ack', function ($delivery_tag, $flags = AMQP_NOPARAM) { }); expect($this->amqp_queue_spy)->toReceive('ack')->with($expected_delivery_tag, Arg::toBeAny()); $this->subscriber->acknowledgeMessage($message_spy); }); }); });