Xdebug, phpunit and vim. "uninitialized" variables in context

I am using this vim plugin https://github.com/ludovicPelle/vim-xdebug using xdebug

Xdebug and the vim plugin work fine with regular scripts. I can view and print the variables.

When I try to run the basic unit test, it gets to the breakpoint and stops, and I can execute the code in order, but I can no longer view the contents of the variables.

I am trying to get this to work with a very simple unit test

class testClass extends \PHPUnit_Framework_TestCase { public function testSomething() { $a = 5; $b = 6; $c = 7; } } 

When I go to the end of the method and try to print the contents of $ a, I get the following error.

 13 : send =====> property_get -i 13 -d 0 -na 13 : recv <===== {{{ <?xml version="1.0" encoding="iso-8859-1"?> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="13" status="break" reason="ok"><error code="300"><message><![CDATA[can not get property]]></message></error></response> }}} response status=break xmlns=urn:debugger_protocol_v1 xmlns:xdebug=http://xdebug.org/dbgp/xdebug reason=ok command=property_get transaction_id=13 error code=300 : Can not get property (when the requested property to get did not exist, this is NOT used for an existing but uninitialized property, which just gets the type "uninitialised" (See: PreferredTypeNames)). message can not get property 

When I print out the whole context, 3 variables are displayed as follows

 $command = 'context_get'; a = /* uninitialized */''; b = /* uninitialized */''; c = /* uninitialized */''; 

I know that phpunit does some interesting tricks when it runs test class methods, so it is possible that the debugger is not returning variables in the method. Any suggestions would be greatly appreciated, thanks.

+4
source share
2 answers

The problem turned out to be the version of xdebug that I used, apparently this is a known issue in version 2.0, which was fixed in 2.1. The virtual machine I'm debugging on is ubuntu 10.04 LTS

At the time this version of Ubuntu was released, xdebug 2.1 was still a candidate for release. I have compiled the latest version of xdebug and I can view the variables in the method.

0
source

You need to do something like this

 class testClass extends \PHPUnit_Framework_TestCase { $a = 0; $b = 0; $c = 0; function dosomething() { $a = 5; $b = 6; $c = 7; } } 

Or you need to include a variable file

your var.php file

<?

  $a = 0; $b = 0; $c = 0; 

? >

0
source

All Articles