dephpugger icon indicating copy to clipboard operation
dephpugger copied to clipboard

Getting Dephpugger to work with PHPunit from the command line

Open purencool opened this issue 4 years ago • 3 comments

Hi, I can't seem to get xdebug_break() to start from the command line. I have reviewed the following documentation https://dephpugger.com/docs/usage/running_with_phpunit, and it states to add thexdebug_break(); in the code where you want to start troubleshooting. After adding the function to the PHPUnit test and running the command, it won't work. Can you see from the information below why it won't break?

When I have added the function https://github.com/purencool/search/blob/master/tests/SSearchGetSearchResultsTest.php.

  public function testAPartialStringRequest()
  {
    xdebug_break(); # <-- Add this line
    $testObj = new Purencool\TestData\TestData();
    $obj = new Purencool\Search\Search($testObj::defaultArray());

To run the tests from the command line I run the following,

./vendor/bin/dephpugger cli  ./vendor/bin/phpunit

The tests run, but dephpugger never breaks.

Time: 72 ms, Memory: 6.00 MB

There was 1 failure:

1) SSearchGetSearchResultsTest::testAPartialStringRequest
Failed asserting that false is true.

/somepath/search/tests/SSearchGetSearchResultsTest.php:46

FAILURES!
Tests: 28, Assertions: 42, Failures: 1.


This is my version of php and xdebug

$ php -v
PHP 7.3.20 (cli) (built: Jul  9 2020 23:55:30) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.20, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.20, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans

$ ./vendor/bin/dephpugger cli -vvv  ./vendor/bin/phpunit
Running file script: ./vendor/bin/phpunit
Command: XDEBUG_CONFIG="idekey=PHPSTORM" /usr/local/Cellar/[email protected]/7.3.20/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9005 -dxdebug.remote_host=127.0.0.1 ./vendor/bin/phpunit
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.


purencool avatar Aug 07 '20 20:08 purencool

The debugger works in another terminal. You must open another terminal and run

$ ./vendor/bin/dephpugger debugger

When application find the breakpoint, should stop and start the debug in the debug terminal

renatocassino avatar Aug 14 '20 15:08 renatocassino

I do have it running in another terminal. When I run the tests it say Connected to XDebug server but will never break on xdebug_break();

image

luisgrases avatar Feb 09 '21 20:02 luisgrases

Nvm found the problem. If I run the test on a separate process, the breakpoint won't work.

    /**
     * @runInSeparateProcess
     * @preserveGlobalState disabled
     */

I removed those test decorators and it worked.

luisgrases avatar Feb 10 '21 05:02 luisgrases