public function testScanSpecifyingPorts()
{
$outputFile = __DIR__ . '/Fixtures/test_scan_specifying_ports.xml';
$expectedCommand = sprintf("nmap -p 21,22,80 -oX '%s' 'williamdurand.fr'", $outputFile);
$executor = $this->getProcessExecutorMock();
$executor->expects($this->at(1))->method('execute')->with($this->equalTo($expectedCommand))->will($this->returnValue(0));
$nmap = new Nmap($executor, $outputFile);
$hosts = $nmap->scan(array('williamdurand.fr'), array(21, 22, 80));
$this->assertCount(1, $hosts);
$host = current($hosts);
$this->assertEquals('204.232.175.78', $host->getAddress());
$this->assertEquals(Host::STATE_UP, $host->getState());
$hostnames = $host->getHostnames();
$this->assertCount(2, $hostnames);
$this->assertEquals('williamdurand.fr', $hostnames[0]->getName());
$this->assertEquals('user', $hostnames[0]->getType());
$this->assertEquals('pages.github.com', $hostnames[1]->getName());
$this->assertEquals('PTR', $hostnames[1]->getType());
$ports = $host->getPorts();
$this->assertCount(3, $ports);
$this->assertEquals(21, $ports[0]->getNumber());
$this->assertEquals('ftp', $ports[0]->getService()->getName());
$this->assertEquals(22, $ports[1]->getNumber());
$this->assertEquals('ssh', $ports[1]->getService()->getName());
$this->assertEquals(80, $ports[2]->getNumber());
$this->assertEquals('http', $ports[2]->getService()->getName());
}