symfony / panther

A browser testing and web crawling library for PHP and Symfony
MIT License
2.94k stars 222 forks source link

Web server hanging on port 9000 #59

Open ChangePlaces opened 6 years ago

ChangePlaces commented 6 years ago

My test isn't running at all, it appears to be pausing until stopped. I've tracked it down to: PantherTestCaseTrait, specifically StartWebServer, and after the lines:

        self::$webServerManager = new WebServerManager($webServerDir, $hostname, $port);
        self::$webServerManager->start();

It would appear the server starts, but then blocks. My test is directly from the examples

        $client = static::createPantherClient(); // Your app is automatically started using the built-in web server
        $crawler = $client->request('GET', '/');
        $this->assertContains('My Title', $crawler->filter('title')->text()); // You can use any PHPUnit assertion

After a bit more digging, it would seem although port 9000 is free, it really will not run on 9000 and hangs. Changing to port 9001 doesn't present any such problem. I'd like to suggest a quick note in the readme as being able to pass in the port isn't immediately obvious.

As seeing nothing during a hung test run, is there some way the server can be tested on the port before starting it without having to do an nmap?

digilist commented 5 years ago

I noticed the same problem and cannot find the reason for it. It's really strange. I got the idea that it is related to XDebug using Port 9000, but even after closing my IDE it still didn't work.

The readme states that the default port is 9080, probably it shouldn't be 9000 after all. So maybe this can be changed?

sqrt-1764 commented 5 years ago

For those who did not find the location in the Readme.md: Besides the parameter in createClient() there is an environment-Variable that controls this: PANTHER_WEB_SERVER_PORT. ;-)