public function it_should_give_specified_connection(Connection $connectionA, Connection $connectionB) { $connectionA->getName()->willReturn('foo'); $connectionB->getName()->willReturn('bar'); $this->addConnection($connectionA); $this->addConnection($connectionB); $this->getConnection('foo')->shouldBeLike($connectionA); $this->getConnection('bar')->shouldBeLike($connectionB); }
public function initialize() { $this->connection->connect(); if (false === $this->channel->isInitialized()) { $this->channel->initialize(); } if (false === $this->exchange->isInitialized()) { $this->exchange->initialize(); } $this->initialized = true; }
public function it_should_configure_connection(Connection $connection, Channel $channel, Exchange $exchange, Queue $queue) { $connection->connect()->shouldBeCalled(); $channel->isInitialized()->willReturn(false); $channel->initialize()->shouldBeCalled(); $exchange->isInitialized()->willReturn(false); $exchange->initialize()->shouldBeCalled(); $queue->isInitialized()->willReturn(false); $queue->initialize()->shouldBeCalled(); $this->initialize(); }
public function it_should_publish_message_with_routing_key_null(EventDispatcher $eventDispatcher, Exchange $exchange, Channel $channel, \AMQPExchange $AMQPExchange, Connection $connection, Identity $identity) { $message = 'foo.bar'; $routingKey = null; $flags = AMQP_NOPARAM; $attributes = ['x-expires' => 1000]; $event = new PublisherEvent($message, $routingKey, $flags, $attributes, $exchange->getWrappedObject()); $successEvent = new SuccessPublisherEvent($event); $connection->connect()->shouldBeCalled(); $channel->isInitialized()->willReturn(true); $exchange->isInitialized()->willReturn(true); $eventDispatcher->dispatch(PublisherEvents::PRE_PUBLISH, $event)->shouldBeCalled(); $AMQPExchange->publish($message, $routingKey, $flags, $attributes)->willReturn(true); $exchange->getWrappedExchange()->willReturn($AMQPExchange); $eventDispatcher->dispatch(PublisherEvents::SUCCESS_PUBLISH, $successEvent)->shouldBeCalled(); $this->publish($message, $routingKey, $flags, $attributes, false)->shouldReturn(true); }
public function initialize() { $this->connection->connect(); $this->channel = new \AMQPChannel($this->connection->getWrappedConnection()); $this->initialized = true; }
/** * @param Connection $connection */ public function addConnection(Connection $connection) { $this->connections[$connection->getName()] = $connection; }