PHPUNIT gives COLOR_AUTO undefined class constant - phpunit

Fatal error: Undefined class constant 'COLOR_AUTO' in C:\xampp\htdocs\zend-doctrine\vendor\phpunit\phpunit\src\Util\Configuration.php on line 584
Call Stack:
0.0018 209368 1. {main}() C:\Users\Bram\AppData\Local\Temp\ide-phpunit.php:0
0.0342 768592 2. IDE_Base_PHPUnit_TextUI_Command::main()
C:\Users\Bram\AppData\Local\Temp\ide-phpunit.php:500
0.0342 771992 3. PHPUnit_TextUI_Command->run()
C:\Users\Bram\AppData\Local\Temp\ide-phpunit.php:243
0.0342 772048 4. IDE_Base_PHPUnit_TextUI_Command->handleArguments()
C:\xampp\php\pear\PHPUnit\TextUI\Command.php:138
0.0342 773256 5. PHPUnit_TextUI_Command->handleArguments()
C:\Users\Bram\AppData\Local\Temp\ide-phpunit.php:248
0.2740 2873064 6. PHPUnit_Util_Configuration->getPHPUnitConfiguration()
C:\xampp\php\pear\PHPUnit\TextUI\Command.php:601

I ran into this error because the phpunit version installed globally on my system (9) was newer than the version in my project (6). I solved this by running PHP unit from the vendor directory as mentioned in this github issue.

Check where is COLOR_AUTO class file and include it in Configuration.php file

It was generated by an old version of PHPSTORM that i was using, bought a new version and it works.

Related

PHP Fatal error returned when creating a new Symfony3 Project [duplicate]

Am new to symfony and from last month am continuously installing new symfony project using following command on ubuntu from the terminal
# Linux, Mac OS X
$ symfony new my_project_name
and it was working perfectly until today, but than just checked the new version release, but now it started giving me following error
Downloading Symfony...
4.93 MB/4.93 MB ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100%
Preparing project...
PHP Warning: require(/var/www/projectname/app/SymfonyRequirements.php): failed to open stream: No such file or directory in phar:///usr/local/bin/symfony/src/Symfony/Installer/DownloadCommand.php on line 265
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/symfony:0
PHP 2. require() /usr/local/bin/symfony:10
PHP 3. Symfony\Component\Console\Application->run() phar:///usr/local/bin/symfony/symfony:35
PHP 4. Symfony\Component\Console\Application->doRun() phar:///usr/local/bin/symfony/vendor/symfony/console/Application.php:126
PHP 5. Symfony\Component\Console\Application->doRunCommand() phar:///usr/local/bin/symfony/vendor/symfony/console/Application.php:195
PHP 6. Symfony\Component\Console\Command\Command->run() phar:///usr/local/bin/symfony/vendor/symfony/console/Application.php:878
PHP 7. Symfony\Installer\NewCommand->execute() phar:///usr/local/bin/symfony/vendor/symfony/console/Command/Command.php:259
PHP 8. Symfony\Installer\DownloadCommand->checkSymfonyRequirements() phar:///usr/local/bin/symfony/src/Symfony/Installer/NewCommand.php:65
PHP Fatal error: require(): Failed opening required '/var/www/projectname/app/SymfonyRequirements.php' (include_path='.:/usr/share/php:/usr/share/pear') in phar:///usr/local/bin/symfony/src/Symfony/Installer/DownloadCommand.php on line 265
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/symfony:0
PHP 2. require() /usr/local/bin/symfony:10
PHP 3. Symfony\Component\Console\Application->run() phar:///usr/local/bin/symfony/symfony:35
PHP 4. Symfony\Component\Console\Application->doRun() phar:///usr/local/bin/symfony/vendor/symfony/console/Application.php:126
PHP 5. Symfony\Component\Console\Application->doRunCommand() phar:///usr/local/bin/symfony/vendor/symfony/console/Application.php:195
PHP 6. Symfony\Component\Console\Command\Command->run() phar:///usr/local/bin/symfony/vendor/symfony/console/Application.php:878
PHP 7. Symfony\Installer\NewCommand->execute() phar:///usr/local/bin/symfony/vendor/symfony/console/Command/Command.php:259
PHP 8. Symfony\Installer\DownloadCommand->checkSymfonyRequirements() phar:///usr/local/bin/symfony/src/Symfony/Installer/NewCommand.php:65
I have even check the symfony at location usr/local/bin/symfony and it was there.
It is a resolved issue that you need to specify the version you want to install. As described here and here, you need to:
Update your installer
>symfony self-update
or with sudo, depending on how you install it:
>sudo symfony self-update
Specify the version:
>symfony new my_project_name 3.0
Hope this helps.
UPDATE
With the correct resolutions of the bug on the Symfony installer, now the 3.0 is the default version. In other case, you can specify the complete version (with minor and major) as follows:
>symfony new my_project_name 3.0.0

Error when running a PHPUnit test

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.

Symfony 2 doctrine fixtures load

I have a problem with
C:\wamp\bin\php\php5.5.12>php c:\wamp\www\symfony\app\console doctrine:fixtures:
load
Fatal error: Class 'Doctrine\Bundle\DoctrineBundle\DoctrineBundle' not found in
C:\wamp\www\Symfony\app\AppKernel.php on line 17
Call Stack:
0.0000 234000 1. {main}() C:\wamp\www\Symfony\app\console:0
0.0650 3390144 2. Symfony\Component\Console\Application->run() C:\wamp\
www\Symfony\app\console:27
0.0770 3622600 3. Symfony\Bundle\FrameworkBundle\Console\Application->d
oRun() C:\wamp\www\Symfony\vendor\symfony\symfony\src\Symfony\Component\Console\
Application.php:124
0.0770 3622824 4. Symfony\Component\HttpKernel\Kernel->boot() C:\wamp\w
ww\Symfony\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\App
lication.php:70
0.0770 3623104 5. Symfony\Component\HttpKernel\Kernel->initializeBundle
s() C:\wamp\www\Symfony\app\bootstrap.php.cache:2303
0.0770 3623512 6. AppKernel->registerBundles() C:\wamp\www\Symfony\app\
bootstrap.php.cache:2473
Line 17 in AppKernel is correct and the file DoctrineBundle exist where it should be.
Anyone knows what is the reason of error?
The Error is clear. You add doctrine bundle to appKernel, but you don't install it (or bad install it ).
This happens when you add to AppKernel the requested namespace bundle (Doctrine\Bundle\DoctrineBundle\DoctrineBundle) before composer ends the installation command.
Try to delete line 17 in the AppKernel, then a composer update and after composer updated your vendors, replace the line 17 as it was

PhpStorm 7.1.3, XDebug 2.2.3, Symfony 2.4 - WebTestCase not found

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

Symfony2 Gregwar / CaptchaBundle Fatal error

I did all steps from
https://github.com/Gregwar/CaptchaBundle
Added to composer.json and updated, config.yml enabled the bundle But I get fatal error
Fatal error: Class 'Gregwar\CaptchaBundle\GregwarCaptchaBundle' not found in /var/www/Surgery/app/AppKernel.php on line 26 Call Stack: 0.0000 228784 1. {main}() /var/www/Surgery/web/app_dev.php:0 0.0037 1211816 2. Symfony\Component\HttpKernel\Kernel->handle() /var/www/Surgery/web/app_dev.php:25 0.0037 1212000 3. Symfony\Component\HttpKernel\Kernel->boot() /var/www/Surgery/app/bootstrap.php.cache:614 0.0037 1212160 4. Symfony\Component\HttpKernel\Kernel->initializeBundles() /var/www/Surgery/app/bootstrap.php.cache:569 0.0037 1212864 5. AppKernel->registerBundles() /var/www/Surgery/app/bootstrap.php.cache:797
I have little problems after update my ubuntu. I' using sf 2.1.6.
I have the same problem with Symfony2.1. I did composer install. I noted that in my output console there was not captcha bundle installed. I fixed the problem with
composer update
In case of somebody bumped into my (similar to this one) problem.
I took code from https://github.com/Gregwar/CaptchaBundle and did all steps (downloaded by git clone). I put the code into \vendor\bundles\Gregwar\CaptchaBundle\
Finally when i got an error
Error: Class 'Gregwar\Captcha\CaptchaBuilder' not found in
D:...\app\cache\dev\appDevDebugProjectContainer.php line
1598
i downloaded another code from https://github.com/Gregwar/Captcha/ and put it into \vendor\bundles\Gregwar\Captcha\
and everything went ok. Hope this will help anybody

Resources