コード例 #1
0
ファイル: ChannelFactorySpec.php プロジェクト: Evaneos/Hector
 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);
 }
コード例 #2
0
 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');
 }
コード例 #3
0
 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);
 }
コード例 #4
0
ファイル: ConnectionFactory.php プロジェクト: Evaneos/Hector
 /**
  * @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;
 }
コード例 #5
0
 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);
 }
コード例 #6
0
ファイル: PublisherFactory.php プロジェクト: Evaneos/Hector
 /**
  * @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);
 }
コード例 #7
0
ファイル: ChannelFactory.php プロジェクト: Evaneos/Hector
 /**
  * @param string   $connectionName
  * @param Identity $identity
  *
  * @return Channel
  */
 public function createFromConnectionName($connectionName, Identity $identity)
 {
     $connection = $this->connectionRegistry->getConnection($connectionName);
     return $this->createFromConnection($connection, $identity);
 }
コード例 #8
0
ファイル: ConsumerFactory.php プロジェクト: Evaneos/Hector
 /**
  * @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);
 }