donatj / mock-webserver

Simple mock web server in PHP for unit testing.
MIT License
131 stars 21 forks source link

Server gets freezed when debugging #20

Closed javierseixas closed 2 years ago

javierseixas commented 5 years ago

Hi, I'm looking forward to been able to test with mock-webserver.

When I debug (I use xDebug) an script that has a request to the MockWebServer, I don't get any response, and the script gets stuck. My hypothesis is that when debugging, the new php process for the server also becomes debugged, and stays waiting for continuing.

The same script works as expected when I'm not debugging. I'm using the scripts sampled in the documentation.

Is there any way to make it debuggable?

Thanks!

javierseixas commented 5 years ago

After some investigation, I've seen that the MockWebServer creates a new process, and this new php process inherits from php configuration. This includes xdebug configuration, and its idekey parameter, which sets a key that the IDE (in my case PHPStorm) will be listening for stopping the process.

Doing some testing, and changing MockWebServer, changing idekey in xdebug solves the problem. Looks like this:

$cmd    = "env XDEBUG_CONFIG='idekey=mock' && php -S {$this->host}:{$this->port} " . escapeshellarg($script);

I'll will do a PR proposing this changes.

donatj commented 2 years ago

On long reflection, I think I'd call this a local environment problem and outside the scope.