Skip to content
Advertisement

PHpUnit with xdebug Breaks at BaseTestRunner instead of the actual test

I have setup Xdebug remote debugging with the following configuration:

I placed a breakpoint in my phpunit test:

<?php declare (strict_types = 1);

namespace TestsApi;

class MyControllerTest extends ApiTestCase
{
    public function myTest()
    {
        // Breakpoint goes here
        //Rest Of code
    }
}

Then I set the Xdebug to listen for the xdebug. ON the remote server (vagrant VM) I run the following commands:

export XDEBUG_CONFIG="idekey=VSCODE"
phpunit ./tests/app/MyControllerTest.php

But my VSCode (ufing vscodium fork) breaks upon vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php Instead of the actual unit test due to refrlection as seen in the xdebug log:

[98] Log opened at 2019-10-18 08:07:04
[98] I: Connecting to configured address/port: 10.0.2.2:9000.
[98] I: Connected to client. :-)
[98] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/vendor/phpunit/phpunit/phpunit" language="PHP" xdebug:language_version="7.2.20" protocol_version="1.0" appid="98" idekey="VSCODE"><engine version="2.7.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2019 by Derick Rethans]]></copyright></init>
[98]
[98] <- breakpoint_list -i 1
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="1"></response>
[98]
[98] <- breakpoint_list -i 2
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="2"></response>
[98]
[98] <- breakpoint_list -i 3
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="3"></response>
[98]
[98] <- breakpoint_list -i 4
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="4"></response>
[98]
[98] <- breakpoint_list -i 5
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="5"></response>
[98]
[98] <- breakpoint_list -i 6
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="6"></response>
[98]
[98] <- breakpoint_set -i 7 -t line -f file:///var/www/html/app/Http/Middleware/AuthorizeGiaolaClient.php -n 26
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id="980001"></response>
[98]
[98] <- breakpoint_set -i 8 -t line -f file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php -n 116
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="8" id="980002"></response>
[98]
[98] <- breakpoint_set -i 9 -t line -f file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php -n 125
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="9" id="980003"></response>
[98]
[98] <- breakpoint_set -i 10 -t line -f file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php -n 127
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="10" id="980004"></response>
[98]
[98] <- breakpoint_set -i 11 -t line -f file:///var/www/html/public/index.php -n 10
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="11" id="980005"></response>
[98]
[98] <- breakpoint_set -i 12 -t line -f file:///var/www/html/app/Communications/Infobip/MessageInterface.php -n 8
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="12" id="980006"></response>
[98]
[98] <- breakpoint_set -i 13 -t line -f file:///var/www/html/app/Controllers/Mobile/V4/ReservationController.php -n 18
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="13" id="980007"></response>
[98]
[98] <- breakpoint_set -i 14 -t line -f file:///var/www/html/tests/Api/Giaola/ReservationControllerTest.php -n 288
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="14" id="980008"></response>
[98]
[98] <- breakpoint_set -i 15 -t line -f file:///var/www/html/tests/Api/Giaola/ReservationControllerTest.php -n 369
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="15" id="980009"></response>
[98]
[98] <- breakpoint_list -i 16
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="16"><breakpoint type="line" filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php" lineno="127" state="enabled" hit_count="0" hit_value="0" id="980004"></breakpoint><breakpoint type="line" filename="file:///var/www/html/public/index.php" lineno="10" state="enabled" hit_count="0" hit_value="0" id="980005"></breakpoint><breakpoint type="line" filename="file:///var/www/html/app/Communications/Infobip/MessageInterface.php" lineno="8" state="enabled" hit_count="0" hit_value="0" id="980006"></breakpoint><breakpoint type="line" filename="file:///var/www/html/app/Controllers/Mobile/V4/ReservationController.php" lineno="18" state="enabled" hit_count="0" hit_value="0" id="980007"></breakpoint><breakpoint type="line" filename="file:///var/www/html/app/Http/Middleware/AuthorizeGiaolaClient.php" lineno="26" state="enabled" hit_count="0" hit_value="0" id="980001"></breakpoint><breakpoint type="line" filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php" lineno="116" state="enabled" hit_count="0" hit_value="0" id="980002"></breakpoint><breakpoint type="line" filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php" lineno="125" state="enabled" hit_count="0" hit_value="0" id="980003"></breakpoint><breakpoint type="line" filename="file:///var/www/html/tests/Api/Giaola/ReservationControllerTest.php" lineno="288" state="enabled" hit_count="0" hit_value="0" id="980008"></breakpoint><breakpoint type="line" filename="file:///var/www/html/tests/Api/Giaola/ReservationControllerTest.php" lineno="369" state="enabled" hit_count="0" hit_value="0" id="980009"></breakpoint></response>
[98]
[98] <- breakpoint_list -i 17
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="17"><breakpoint type="line" filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php" lineno="127" state="enabled" hit_count="0" hit_value="0" id="980004"></breakpoint><breakpoint type="line" filename="file:///var/www/html/public/index.php" lineno="10" state="enabled" hit_count="0" hit_value="0" id="980005"></breakpoint><breakpoint type="line" filename="file:///var/www/html/app/Communications/Infobip/MessageInterface.php" lineno="8" state="enabled" hit_count="0" hit_value="0" id="980006"></breakpoint><breakpoint type="line" filename="file:///var/www/html/app/Controllers/Mobile/V4/ReservationController.php" lineno="18" state="enabled" hit_count="0" hit_value="0" id="980007"></breakpoint><breakpoint type="line" filename="file:///var/www/html/app/Http/Middleware/AuthorizeGiaolaClient.php" lineno="26" state="enabled" hit_count="0" hit_value="0" id="980001"></breakpoint><breakpoint type="line" filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php" lineno="116" state="enabled" hit_count="0" hit_value="0" id="980002"></breakpoint><breakpoint type="line" filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemManager.php" lineno="125" state="enabled" hit_count="0" hit_value="0" id="980003"></breakpoint><breakpoint type="line" filename="file:///var/www/html/tests/Api/Giaola/ReservationControllerTest.php" lineno="288" state="enabled" hit_count="0" hit_value="0" id="980008"></breakpoint><breakpoint type="line" filename="file:///var/www/html/tests/Api/Giaola/ReservationControllerTest.php" lineno="369" state="enabled" hit_count="0" hit_value="0" id="980009"></breakpoint></response>
[98]
[98] <- breakpoint_set -i 18 -t exception -x *
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="18" id="980010"></response>
[98]
[98] <- run -i 19
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="19" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php" lineno="114" exception="ReflectionException"><![CDATA[Method suite does not exist]]></xdebug:message></response>
[98]
[98] <- stack_get -i 20
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="20"><stack where="ReflectionClass-&gt;getMethod" level="0" type="file" filename="file:///var/www/html/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php" lineno="114"></stack><stack where="PHPUnitTextUITestRunner-&gt;getTest" level="1" type="file" filename="file:///var/www/html/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php" lineno="114"></stack><stack where="PHPUnitTextUICommand-&gt;run" level="2" type="file" filename="file:///var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php" lineno="183"></stack><stack where="PHPUnitTextUICommand::main" level="3" type="file" filename="file:///var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php" lineno="162"></stack><stack where="{main}" level="4" type="file" filename="file:///var/www/html/vendor/phpunit/phpunit/phpunit" lineno="61"></stack></response>
[98]
[98] <- run -i 21
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="21" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php" lineno="255" exception="SymfonyComponentHttpKernelExceptionMethodNotAllowedHttpException"><![CDATA[]]></xdebug:message></response>
[98]
[98] <- run -i 22
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="22" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/vendor/laravel/framework/src/Illuminate/View/FileViewFinder.php" lineno="137" exception="InvalidArgumentException"><![CDATA[View [405] not found.]]></xdebug:message></response>
[98]
[98] <- run -i 23
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="23" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php" lineno="112" exception="PHPUnitFrameworkExpectationFailedException"><![CDATA[Expected status code 404 but received 405.
Failed asserting that false is true.]]></xdebug:message></response>
[98]
[98] <- run -i 24
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="24" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php" lineno="112" exception="PHPUnitFrameworkExpectationFailedException"><![CDATA[Expected status code 404 but received 405.
Failed asserting that false is true.]]></xdebug:message></response>
[98]
[98] <- run -i 25
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="25" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php" lineno="112" exception="PHPUnitFrameworkExpectationFailedException"><![CDATA[Expected status code 404 but received 405.
Failed asserting that false is true.]]></xdebug:message></response>
[98]
[98] <- run -i 26
[98] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="26" status="stopping" reason="ok"></response>
[98]
[98] <- run -i 27
[98] Log closed at 2019-10-18 08:07:34
[98]

So how I can make the xgebug the my test function signature?

Advertisement

Answer

I was having the same problem. Check on your lower left, on “Breakpoints” section of the debug sidebar, if “Everything” is ticked. Untick it.

Look on the following screenshot for how to uncheck it: enter image description here

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement