Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MarcTroesken's avatar

Where are my PHPUnit colors :D

Hi,

any ideas why I can´t see the green or red color when testing with Laracasts\Integrated ?

In my phpunit.xml file colors are set to true. But theres nothing to see in my console :(

0 likes
11 replies
bobbybouwmann's avatar

You can do it like this

./vendor/bin/phpunit --colors 

If you want more help then we need to see your phpunit.xml file

3 likes
BENderIsGr8te's avatar

Hey guys, having a similar issue.

I use iTerm 2 with Oh My Zsh (like Jeffrey advises).

I notice however, that on my Homestead box, I don't get any colors in the terminal other than the colors that are display from Artisan commands.

My Oh My Zsh theme (cloud) isn't working on the SSH (I installed it from the Homestead box, but I am having trouble figuring out how to tell homestead to use it).

When I run phpunit I don't get any colors even though the XML file is set to colors. The XML file is the default file that ships with Laravel 5

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="bootstrap/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         syntaxCheck="false">
    <testsuites>
        <testsuite name="Application Test Suite">
            <directory>./tests/</directory>
        </testsuite>
    </testsuites>
    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
    </php>
</phpunit>

And my terminal output looks like this (with no colors..the colors you see below are automatically added by the syntax highlighter)

PHPUnit 4.6.6 by Sebastian Bergmann and contributors.

Configuration read from /home/vagrant/ExpressRentals/phpunit.xml

.

Time: 6.46 seconds, Memory: 15.75Mb

OK (1 test, 1 assertion)

Any thoughts? Or are colors something that won't work in terminal when SSH'd in?

ZetecVan's avatar

I've had this problem too. I noticed my most recent Laravel 5 install was showing colours, but the Lumen install I did yesterday wasn't.

I noticed that Lumen had PHPUnit version 4.6.6 but the Laravel 5 install was showing as PHPUnit 4.5.0.

Changing your composer.json to require "phpunit/phpunit": "4.5.0" should solve the problem.

1 like
BENderIsGr8te's avatar

So that's weird. But that solved my PHP Unit color issues. I'm still having issues with my Oh My Zsh colors, but that's a different SSH issue :)

kuroski's avatar

Try this:

Open your terminal and type:

// on the root of your project
vendor/bin/phpunit
4 likes
adrianorosa's avatar

This issue is caused when you are using different version of phpunit on your system, for example, your package is 4.7 and your system is 4.2 then your tests output will not get colored because of that, this is NOT a phpunit related issue.

To FIX this problem update your system version of phpunit by running:

phpunit self-update
AdiInviter's avatar

Try using "--colors=always" flag while running your test.

For e.g. You can run it like this from your terminal or GitBash :

vendor/bin/phpunit --colors=always tests
6 likes
lugom's avatar

you can set the phpunit.xml:

<phpunit colors="true"

Please or to participate in this conversation.