/** * @inheritdoc */ protected function setUp() { parent::setUp(); $this->mockSocket = m::mock('\\Hitmeister\\Component\\Metrics\\Socket\\Socket'); $this->mockSocket->shouldReceive('close')->once(); $this->mockSocket->shouldReceive('connectTimeout')->withArgs([$this->testHost . ':' . $this->testPort, $this->testTimeout])->once(); $this->mockFactory = m::mock('\\Hitmeister\\Component\\Metrics\\Socket\\Factory'); $this->mockFactory->shouldReceive('createUdp4')->andReturn($this->mockSocket); }
/** * Connects to the udp\tcp server */ public function connect() { // @codeCoverageIgnoreStart if (null !== $this->socket) { return; } if (null === $this->factory) { $this->factory = new Factory(); } // @codeCoverageIgnoreEnd // Create socket $socket = 'tcp' === $this->scheme ? $this->factory->createTcp4() : $this->factory->createUdp4(); $socket->connectTimeout($this->host . ':' . $this->port, $this->timeout); $this->socket = $socket; }