Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Dephpugger to work with PHPunit from the command line #49

Open
purencool opened this issue Aug 7, 2020 · 3 comments
Open

Getting Dephpugger to work with PHPunit from the command line #49

purencool opened this issue Aug 7, 2020 · 3 comments

Comments

@purencool
Copy link
Contributor

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/php@7.3/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.


@renatocassino
Copy link
Owner

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

@luisgrases
Copy link

luisgrases commented Feb 9, 2021

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
Copy link

luisgrases commented Feb 10, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants