1

I'm trying to execute a PHPUnit test via the CLI to debug in via PhpStorm, being on a Ubuntu 16.04 operating system. It's a KernelTestBase unit test for Drupal 8. The normal execution of the test - without PhpStorm and Xdebug - works. The problem appears, when I have XDebug switched on. I'm executing it that way from the terminal:

peter@computer ~/Websites/pbt-d8 $ vendor/bin/phpunit -c modules/permissions_by_term modules/permissions_by_term/tests/src/Kernel/SelectTermTest.php

If XDebug is switched on, PhpStorm shows me a weird "Remote file path error":

Remote file path '/home/peter/Websites/pbt-d8/-' is not mapped to any file path in project

I have also attached a screenshot of the debug window: enter image description here

What confuses me here, is the "-" character at the end of the path. I have not specified this character anywhere.

I have no idea what I should define here as a path mapping within PhpStorm: enter image description here

My phpunit.xml file (which is located at modules/permissions_by_term/phpunit.xml) looks like follows:

<phpunit bootstrap="tests/bootstrap.php" colors="true"
         beStrictAboutTestsThatDoNotTestAnything="true"
         beStrictAboutOutputDuringTests="true"
         beStrictAboutChangesToGlobalState="true"
         checkForUnintentionallyCoveredCode="false"
         printerClass="\Drupal\Tests\Listeners\HtmlOutputPrinter">
  <php>
    <!-- Set error reporting to E_ALL. -->
    <ini name="error_reporting" value="32767"/>
    <!-- Do not limit the amount of memory tests take to run. -->
    <ini name="memory_limit" value="-1"/>
    <!-- Example SIMPLETEST_BASE_URL value: http://localhost -->
    <!-- Example SIMPLETEST_DB value: mysql://username:password@localhost/databasename#table_prefix -->
    <env name="SIMPLETEST_DB" value="mysql://root:password@localhost/pbt-d8"/>
    <env name="SIMPLETEST_BASE_URL" value="http://pbt-d8"/>
    <!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output -->
    <env name="BROWSERTEST_OUTPUT_DIRECTORY" value="/home/peter/d8-tests"/>
    <env name="PHP_IDE_CONFIG" value="serverName=pbt-d8"/>
    <env name="XDEBUG_CONFIG" value="remote_enable=1 remote_mode=req remote_port=9000 remote_host=127.0.0.1 remote_connect_back=0"/>
  </php>
</phpunit>

Do you know what's wrong here? Do I need any specific XDebug configuration to fix this issue here?

2 Answers 2

1

You can disable "Force break at first line when no path mapping specified" in "Debug" settings and this error goes away. While execution is paused, you can see that the break is happening in a secondary callback that is called with - as an argument (See $_SERVER['argv'][0]).

This doesn't happen with purely unit tests because there isn't a secondary callback but BrowserTestBase. KernelTestBase must be working simillarly to BrowserTestBase.

0

There was a bug within my code. I have forced the debugger to stop via xdebug_break(); and found out that the issue was at the first line of my code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.