Ejemplo n.º 1
0
 public function testGetPortReturnsValidPort()
 {
     $util = new PortUtil();
     $port = $util->getPort(rand(10000, 50000));
     $this->assertTrue($util->validatePort($port));
     $this->setExpectedException('Exception', 'Failed to find a port');
     $util->getPort(70000);
 }
 /**
  * Automatically determine the best port for a new tunnel.
  *
  * @param int $default
  *
  * @return int
  */
 protected function getPort($default = 30000)
 {
     $ports = [];
     foreach ($this->getTunnelInfo() as $tunnel) {
         $ports[] = $tunnel['localPort'];
     }
     return PortUtil::getPort($ports ? max($ports) + 1 : $default);
 }