/** * @param ExchangeLocator $exchangeLocator * @param int $responseTimeout The time to wait for a response in millisecond * @param int|null $queueTimeout The time before the amqp server removes the response queue in millisecond * @param int $waitInterval The interval between response checks in millisecond */ public function __construct(ExchangeLocator $exchangeLocator, $responseTimeout = 1000, $queueTimeout = null, $waitInterval = 10) { parent::__construct($exchangeLocator); $this->responseTimeout = $responseTimeout / 1000; $this->queueTimeout = $queueTimeout; $this->responseWaitInterval = $waitInterval * 1000; }
/** * @test */ public function it_should_wrap_amqp_exception() { $message = new MessageCommand('message', 'key'); $exchange = Mockery::mock(\AMQPExchange::class); $exchange->shouldReceive('publish')->once()->with($message->getMessage(), $message->getRoutingKey(), $message->getFlags(), $message->getAttributes())->andThrow(\AMQPConnectionException::class); $this->locator->shouldReceive('getExchangeForMessage')->atLeast()->once()->with($message)->andReturn($exchange); try { $this->publisher->publish($message); $this->fail('A exception should have been throw by exchange::publish'); } catch (FailedToPublishException $e) { $this->assertInstanceOf(\AMQPConnectionException::class, $e->getPrevious(), 'Expected the previous exception to be the throw to be a \\AMQPConnectionException'); return; } catch (\Exception $e) { $this->fail(sprintf('A exception of type %s was expected but got %s', \AMQPConnectionException::class, get_class($e))); } }