示例#1
0
 public function testGet()
 {
     $connection = new AmqpConnection();
     $connection->setConfig(['host' => $this->faker->ipv4, 'port' => $this->faker->randomDigit()]);
     $this->assertEquals('AMQPConnection', get_class($connection->get()));
     $amqpConnection = $this->getMockBuilder('AMQPConnection')->setMethods(['isConnected'])->getMock();
     $amqpConnection->expects($this->once())->method('isConnected')->willReturn(false);
     $connection->connection = $amqpConnection;
     $connection->get();
 }
<?php

use Amqp\Connection;
use NwWebsite\Di;
$connection = new Connection();
$di = Di::getInstance();
$config = $di->config->get('amqp');
$connection->setConfig(['host' => $config->host, 'port' => $config->port]);
return $connection;