/** * @return ChannelInterface */ protected function getChannel() { if (!$this->channel) { $this->channel = $this->connection->channel(1); } return $this->channel; }
/** * {@inheritdoc} */ protected function setUp() { if (!isset($_SERVER['AMQP_URL'])) { $this->markTestSkipped('This test require AMQP Server, use AMQP_URL environment variables to set connection details'); } $this->exchange = uniqid('phpunit.'); $env = function ($key, $default = null) { return isset($_SERVER[$key]) ? $_SERVER[$key] : $default; }; $this->connection = ConnectionBuilder::make()->create($env('AMQP_URL', '')); $this->handler = $this->createMock(HandlerInterface::class); $this->channel = $this->connection->channel(); $this->consumer = new Consumer($this->connection, $this->handler); }
/** * {@inheritdoc} */ protected function setUp() { if (!isset($_SERVER['AMQP_URL'])) { $this->markTestSkipped('This test require AMQP Server, use AMQP_URL environment variables to set connection details'); } $this->exchange = uniqid('phpunit.'); $env = function ($key, $default = null) { return isset($_SERVER[$key]) ? $_SERVER[$key] : $default; }; $this->connection = ConnectionBuilder::make()->create($env('AMQP_URL', '')); $this->channel = $this->connection->channel(); $this->channel->exchange($this->exchange)->define('fanout'); $this->client = new ServiceBus(new ArrayDiscovery([new Endpoint(new Identity('calc', ['amqp://localhost/?exchange=' . $this->exchange]), new Driver($this->connection, ''))]), new Broadcaster($this->connection, $this->exchange)); $this->initialize(); }