Nmap\Tests\NmapTest::testScanWithServiceInfo PHP Метод

testScanWithServiceInfo() публичный Метод

    public function testScanWithServiceInfo()
    {
        $outputFile = __DIR__ . '/Fixtures/test_scan_with_service_info.xml';
        $expectedCommand = sprintf("nmap -sV -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->enableServiceInfo()->scan(array('williamdurand.fr'));
        $host = current($hosts);
        $ports = $host->getPorts();
        $service = $ports[0]->getService();
        $this->assertEquals('ssh', $service->getName());
        $this->assertEquals('OpenSSH', $service->getProduct());
        $this->assertEquals('5.1p1 Debian 5github8', $service->getVersion());
        $service = $ports[1]->getService();
        $this->assertEquals('http', $service->getName());
        $this->assertEquals('nginx', $service->getProduct());
    }