Пример #1
0
 public function testGetPortDoesNotReturnPortInUse()
 {
     $util = new PortUtil();
     $port = $util->getPort();
     $this->assertFalse($util->isPortInUse($port));
     // Find a listening local port, try getPort() on the port number and
     // test that a new number is returned.
     exec('lsof -sTCP:LISTEN -i@127.0.0.1 -P -n', $output, $returnVar);
     if ($returnVar === 0 && preg_match('/127\\.0\\.0\\.1:([0-9]+)/', end($output), $matches)) {
         $openPort = $matches[1];
         $this->assertNotEquals($util->getPort($openPort), $openPort);
     } else {
         $this->markTestIncomplete('Failed to find open port');
     }
 }