public function testDestruct() { $this->channelMock->expects($this->once())->method('close'); $this->clientMock->expects($this->once())->method('close'); $queue = new MessageQueue($this->clientMock); unset($queue); }
/** * Test declaring a queue on the channel using the configured queue name */ public function testQueueDeclaration() { $qName = 'queue_name'; $this->setStubConfigData(['getQueueName' => $qName, 'getQueueConfiguration' => ['queue' => $qName, 'passive' => false, 'durable' => true, 'exclusive' => true, 'auto_delete' => true, 'nowait' => true]]); $this->channel->expects($this->once())->method('queue_declare')->with($this->identicalTo($qName)); $this->invokeRestrictedMethod($this->amqpApi, 'declareQueue'); }
/** * Driver should compose AMQP message and publish it to the channel. */ public function testPublish() { $reply = $this->getMockBuilder(Invoker\Reply::class)->disableOriginalConstructor()->getMock(); $this->channel->expects($this->once())->method('basic_publish')->willReturnCallback(function (AMQPMessage $message, $exchange, $routingKey) use($reply) { $headers = ['base' => 'dec', 'to' => 'calc', 'topic' => 'add', 'version' => '1.0']; $this->assertJsonStringEqualsJsonString('{"a": 10, "b": 53}', $message->body); $this->assertEquals($headers, $message->get('application_headers')->getNativeData()); $this->assertEquals($this->exchange, $exchange); $this->assertEquals('add', $routingKey); return $reply; }); $this->driver->publish(new Location('calc'), $this->createRequest()); }
/** * Preparing AMQP Channel Expectations * * @param $expectedMethod * @param $expectedRequeue * * @return void */ private function prepareAMQPChannelExpectations($expectedMethod, $expectedRequeue) { $this->amqpChannel->expects($this->any())->method('basic_reject')->will($this->returnCallback(function ($delivery_tag, $requeue) use($expectedMethod, $expectedRequeue) { \PHPUnit_Framework_Assert::assertSame($expectedMethod, 'basic_reject'); // Check if this function should be called. \PHPUnit_Framework_Assert::assertSame($requeue, $expectedRequeue); // Check if the message should be requeued. })); $this->amqpChannel->expects($this->any())->method('basic_ack')->will($this->returnCallback(function ($delivery_tag) use($expectedMethod) { \PHPUnit_Framework_Assert::assertSame($expectedMethod, 'basic_ack'); // Check if this function should be called. })); }
public function testCallReplyResolving() { $message = $this->createMessage(); $this->channel->expects($this->once())->method('basic_publish'); $this->invoker->call($message, '', '')->resolve(10); }
private function ensureAcknowledgement(AMQPChannel $channel, $deliveryTag) { $channel->expects($this->once())->method('basic_ack')->with($this->equalTo($deliveryTag)); }
/** * @test */ public function it_does_not_publish_a_domain_message_when_specification_is_not_satisfied() { $this->expectSpecificationIsNotSatisfied(); $this->amqpChannel->expects($this->never())->method('basic_publish'); $this->amqpPublisher->handle($this->domainMessage); }