Viewed   322 times

So I have PHPUnit running in PHPStorm 7.1, but I can't find out how to get the ANSI color codes working from within tests. My PHPunit.xml has colors = "true" in the property list, but every time I try something like:

echo "33[31mError! Error!33[0mn";

Inside one of my test cases, it just gives me:

[31mError! Error![0m

in the PHPstorm phpunit output. Is there any way to make the colors appear properly when using ANSI color codes in tests in PHPStorm?

 Answers

2

PhpStorm has special integration script to run PHPUnit tests (all messages/progress indicators are transferred into GUI part where you can easily see what tests have passed and what did not etc).

PhpStorm's console does not support ANSI colors -- http://youtrack.jetbrains.com/issue/IDEA-69880 and related tickets.

But you can install Grep Console plugin and it will add support for ANSI colors (needs to be activated in Settings). I have tried it with PHPUnit and it worked -- not everything was colored (some of the codes were not recognized, but most worked). You can contact plugin author with not working parts if desired.

Wednesday, November 16, 2022
 
1

You should point to your vendor/autoload.php at Settings | PHP | PHPUnit when using PHPUnit via Composer.

This blog post has all the details (with pictures) to successfully configure IDE for such scenario: http://confluence.jetbrains.com/display/PhpStorm/PHPUnit+Installation+via+Composer+in+PhpStorm

Related usability ticket: http://youtrack.jetbrains.com/issue/WI-18388

P.S. The WI-18388 ticket is already fixed in v8.0

Sunday, July 31, 2022
 
4

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Sunday, November 6, 2022
1

PhpStorm generates special temporary "wrapping" to execute the tests and get the output in the form it understands better. In your case it's /private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php. Since the error says there is a syntax error, the first thing you should try is deleting it, on the next run the IDE will create the new one, hopefully without that problem.

If that doesn't help, as suggested in the comments, try downgrading the PHPUnit a few versions back, see if that helps. Alternatively try reinstalling the PhpStorm. If that doesn't work, you have better chances of finding an answer by reporting an issue to the dev team.

Saturday, October 22, 2022
4

Silly mistake on my part... simply forgot to add phpunit as a dependency in the project. For anyone else that gets this error, to composer.json add:

"require-dev": {
    "phpunit/phpunit": "3.7.*"
},

And then run:

composer update

That solved the problem.

Sunday, November 27, 2022
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :