I don't want to turn on xdebug code coverage for all scripts but I do want to be able to turn it on for a daily jenkins build which produces the code coverage.
I tried the following
phpunit -d xdebug.coverage_enable=1 -c phpunit-coverage.xml.dist
However I always get the following error
Configuration read from phpunit-coverage.xml.dist
Fatal error: Uncaught exception 'PHP_CodeCoverage_Exception' with message 'You need to set xdebug.coverage_enable=On in your php.ini.' in /usr/local/lib/php/PHP/CodeCoverage/Driver/Xdebug.php on line 72
PHP_CodeCoverage_Exception: You need to set xdebug.coverage_enable=On in your php.ini. in /usr/local/lib/php/PHP/CodeCoverage/Driver/Xdebug.php on line 72
Call Stack:
0.0002 627488 1. {main}() /usr/local/bin/phpunit:0
0.0050 1095880 2. PHPUnit_TextUI_Command::main() /usr/local/bin/phpunit:46
0.0050 1096608 3. PHPUnit_TextUI_Command->run() /usr/local/lib/php/PHPUnit/TextUI/Command.php:130
0.6419 39830848 4. PHPUnit_TextUI_TestRunner->doRun() /usr/local/lib/php/PHPUnit/TextUI/Command.php:192
0.9760 40345400 5. PHP_CodeCoverage->__construct() /usr/local/lib/php/PHPUnit/TextUI/TestRunner.php:258
0.9764 40358504 6. PHP_CodeCoverage_Driver_Xdebug->__construct() /usr/local/lib/php/PHP/CodeCoverage.php:119
Any ideas as to how I can get this to work, without having to change php.ini each time?
Yes, it can but only by running it like this:
php -dxdebug.mode=coverage bin/phpunit --coverage-clover='reports/coverage/coverage.xml' --coverage-html='reports/coverage'
Note: "..Xdebug: [Config] The setting 'xdebug.coverage_enable' has been renamed,.."
With php 7.4 and phpunit 9, it's possible set options with env
XDEBUG_MODE=coverage /usr/bin/phpunit
Using php 7.4 I has to use -d xdebug.mode=coverage
Because I use php -n my full line was -d zend_extension=xdebug.so -d xdebug.mode=coverage
In the end I discovered you cannot do what I originially wanted.
Instead the answer is to add second php.ini file which has xdebug and coverage enabled. Then
in my build.xml I used the following to run it.
php -c /usr/local/lib/php-coverage.ini /usr/bin/phpunit -c app/
Related
I have a problem with this command : php bin/console server:run on Symfony 4
When I go to http://127.0.0.1:8000/ I have this error message :
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'J:\my_project\vendor\symfony\web-server-bundle/Resources/router.php' (include_path='.;C:\php\pear') in Unknown on line 0
Indeed, the router.php file does not exist !
But if I run this command : php -S 127.0.0.1:8000 -t public everything is ok.
Any idea ?
First check that you have installed the SF4 Web Server bundle :
> composer require server --dev
then you can start using it through Symfony using run / start command
Not sure if this is the case for you too, but it is probably worth checking (and may also be interesting for others having the same problem).
My antivirus software likes to put the router.php in quarantine (effectively removing it from that directory). Check if yours did the same and if so restore it and create an exception for that file. Additionally you should configure your antivirus to notify you if it puts something in quarantine, so you can intervene in time.
I get an error when I try to run a test in PHPUnit. Even if I type phpunit by itself, I still get an error. It works fine when I call it outside the Bootstrap folder.
Configuration read from /home/milen/Documents/codific/icho/module/Application/tests/phpunit.xml
PHP Fatal error: Call to a member function getId() on a non-object in /home/milen/Documents/codific/icho/module/Application/tests/ApplicationTest/Controller/PoCourseTest.php on line 268
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:129
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:176
PHP 5. PHPUnit_Framework_TestSuite->run() /home/milen/Documents/codific/icho/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:426
PHP 6. PHPUnit_Extensions_SeleniumTestCase->run() /home/milen/Documents/codific/icho/vendor/phpunit/phpunit/src/Framework/TestSuite.php:699
PHP 7. PHPUnit_Framework_TestCase->run() /home/milen/Documents/codific/icho/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumTestCase.php:648
PHP 8. PHPUnit_Framework_TestResult->run() /home/milen/Documents/codific/icho/vendor/phpunit/phpunit/src/Framework/TestCase.php:760
PHP 9. PHPUnit_Framework_TestCase->runBare() /home/milen/Documents/codific/icho/vendor/phpunit/phpunit/src/Framework/TestResult.php:686
PHP 10. PoCourseTest->tearDown() /home/milen/Documents/codific/icho/vendor/phpunit/phpunit/src/Framework/TestCase.php:852
I tried reinstalling it, no luck.
I usually see an error along these lines when I have defined a bootstap.php file to run for PHPUnit which gets specified in the phpunit.xml file. With this setup, you need to be careful from where you run your tests so that the bootstrap file is run properly. This isn't a problem of PHPUnit per se, but a side effect from the phpunit.xml file.
This would appear to be the case because you stated that when you are not in the folder called "Bootstrap" (what / where ever that is), PHPUnit works fine. But without more information aside from the error dump this would be difficult to ascertain.
I think this question could be fixed with this answer.
I don't think its a problem with configuration, but rather a code execution in the setUp and tearDown method.
When I type:
php -info
I get this error message:
Could not open input file: o
I have php 5.4 installed. Trying to find info to configure IIS.
This was easy. Found the answer in an IIS forum.
http://forums.iis.net/t/1189386.aspx?Installing+PHP+on+IIS7
The -info flag has been depreciated. Its just -i now
Try php -i.
php -info will be interpreted as php -inf o so cause that error.
I'm getting the following error when attempting to run my own Symfony unit tests in PhpStorm:
/usr/bin/php /home/kevin/www/src/Blah/MyBundle/Tests/Controller/HomeControllerTest.php
PHP Fatal error: Class 'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found in /home/kevin/www/src/Blah/MyBundle/Tests/Controller/HomeControllerTest.php on line 8
PHP Stack trace:
PHP 1. {main}() /home/kevin/www/src/Blah/MyBundle/Tests/Controller/HomeControllerTest.php:0
Fatal error: Class 'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found in /home/kevin/www/src/Blah/MyBundle/Tests/Controller/HomeControllerTest.php on line 8
Call Stack:
0.0002 234112 1. {main}() /home/kevin/www/src/Blah/MyBundle/Tests/Controller/HomeControllerTest.php:0
Process finished with exit code 255
Some research has informed me that I may have to point PhpStorm/Xdebug to Symfony's bootstrap and/or test suite XML file, but I'm not sure how to do that in PhpStorm. Nothing is jumping out at me in the various config screens. Please help.
Although I'm using IntelliJ IDEA, the configuration is the same, so:
Settings -> PHP -> PHPUnit - there are inputs for bootstrap and config
I renamed my working trunk to trunk-alldone, checked out a fresh copy of trunk, ran some symfony commands (like unit tests) on trunk, then deleted trunk and renamed trunk-alldone back to trunk.
Now when I try to run any symfony commands, I get:
sym cc
PHP Warning: require(/home/kiwi/checkouts/trunk-alldone/kiwi- web/plugins/kcEmailPlugin/l pleAutoload.class.php on line 123
PHP Stack trace:
PHP 1. {main}() /home/kiwi/checkouts/trunk/kiwi-web/symfony:0
PHP 2. include() /home/kiwi/checkouts/trunk/kiwi-web/symfony:37
PHP 3. sfCommandApplication->__construct() /home/kiwi/checkouts/trunk/kiwi-web/lib/vend
PHP 4. sfSymfonyCommandApplication->configure() /home/kiwi/checkouts/trunk/kiwi-web/lib
PHP 5. sfSymfonyCommandApplication->loadTasks() /home/kiwi/checkouts/trunk/kiwi-web/lib
PHP 6. class_exists() /home/kiwi/checkouts/trunk/kiwi-web/lib/vendor/symfony/lib/comman
PHP 7. sfSimpleAutoload->autoload() /home/kiwi/checkouts/trunk/kiwi-web/lib/vendor/symf
It's still looking for things in trunk-alldone!
How do I reset this to get it to look in the right place again?