Search code examples
phpphpunitphpstorm

PHPStorm + PHPUnit Color output


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 "\033[31mError! Error!\033[0m\n";

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?


Solution

  • 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.