public function it_should_create_channel_from_connection_name(ConnectionRegistry $connectionRegistry, ChannelRegistry $channelRegistry, Connection $connection, Identity $identity) { $connectionRegistry->getConnection('default')->willReturn($connection); $channel = $this->createFromConnectionName('default', $identity); $channelRegistry->addChannel($channel)->shouldHaveBeenCalled(); $channel->shouldBeAnInstanceOf(Channel::class); }
public function it_should_create_configured_connection(ConnectionRegistry $registry) { /** @var Connection $connection */ $connection = $this->createNamed('default')->shouldReturnAnInstanceOf(Connection::class); $registry->addConnection($connection)->shouldHaveBeenCalled(); Assertion::eq($connection->getWrappedConnection()->getVhost(), 'foo'); }
public function it_should_create_exchange_from_connection_name(ConnectionRegistry $connectionRegistry, Connection $connection, ChannelFactory $channelFactory, ExchangeRegistry $exchangeRegistry, ExchangeFactory $exchangeFactory, Channel $channel, Exchange $exchange) { $connectionRegistry->getConnection('default')->willReturn($connection); $channelFactory->createFromConnection($connection, Argument::type(Identity::class))->willReturn($channel); $exchangeRegistry->hasExchange('exchange', $channel)->willReturn(false); $exchangeFactory->createNamed('exchange', $channel)->willReturn($exchange); $this->create('default', 'exchange')->shouldReturnAnInstanceOf(Publisher::class); }
/** * @param $name * * @throws HectorException * * @return Connection */ public function createNamed($name) { if (!isset($this->configs[$name])) { throw new HectorException(sprintf('Unable to load config for connection %s', $name)); } $connection = new Connection(new \AMQPConnection($this->configs[$name]), $name); $this->registry->addConnection($connection); return $connection; }
public function it_should_reuse_existing_exchange_when_its_same_channel_and_same_exchange(ConnectionRegistry $connectionRegistry, Connection $connection, ChannelFactory $channelFactory, Channel $channel, Exchange $exchange, Queue $queue, ExchangeRegistry $exchangeRegistry, QueueRegistry $queueRegistry) { $connectionRegistry->getConnection('default')->willReturn($connection); $channelFactory->createFromConnection($connection, Argument::type(Identity::class))->willReturn($channel); $exchangeRegistry->hasExchange('exchange', $channel)->willReturn(true); $exchangeRegistry->getExchange('exchange', $channel)->willReturn($exchange); $queueRegistry->hasQueue('queue', $channel, $exchange)->willReturn(true); $queueRegistry->getQueue('queue', $channel, $exchange)->willReturn($queue); $consumer = $this->createFromConnection($connection, 'exchange', 'queue'); $consumer->shouldBeAnInstanceOf(Consumer::class); }
/** * @param string $connectionName * @param string $exchangeName * @param array $options * * @return Publisher */ public function create($connectionName, $exchangeName, Channel $channel = null, array $options = []) { $connection = $this->connectionRegistry->getConnection($connectionName); return $this->createFromConnection($connection, $exchangeName, $channel, $options); }
/** * @param string $connectionName * @param Identity $identity * * @return Channel */ public function createFromConnectionName($connectionName, Identity $identity) { $connection = $this->connectionRegistry->getConnection($connectionName); return $this->createFromConnection($connection, $identity); }
/** * @param string $connectionName * @param string $exchangeName * @param string $queueName * * @return Consumer */ public function create($connectionName, $exchangeName, $queueName) { $connection = $this->connectionRegistry->getConnection($connectionName); return $this->createFromConnection($connection, $exchangeName, $queueName); }