I'm testing under Windows and the command prompt doesn't do so well with the ANSI color codes that appear by default. How can I turn off the color display when I'm using Laravel?
Laravel will create a basic test class that looks like this: It is good to find out the default Laravel phpunit.xml file before running your test suite. PHPUnit will itself locate for the file naming phpunit.xml or phpunit.xml.dist in its current execution directory. Within this file, you can configure specific operations for your tests.
The purpose of this tutorial is to introduce you to the basics of PHPUnit testing, using both the default PHPUnit assertions and the Laravel test helpers. The aim is for you to be confident in writing basic tests for your applications by the end of the tutorial.
This allows us to use Laravel facades in tests and provides the framework for the testing helpers, which we will look at shortly. To create a new test class, we can either create a new file manually or run the helpful Artisan make:test command provided by Laravel.
Earlier in this Laravel unit testing example, we saw the default files within the /tests/ directory and left the ./tests/ExampleTest.php file to review at the later stage. So open it now, it should look like this:
The file \laravel\cli\tasks\test\stub.xml is used to generate the PhpUnit configuration file for tests. (A new configuration file is generated and deleted every time you run an artisan test task.) To turn off colors, change the first line of stub.xml from <phpunit colors="true"
to <phpunit colors="false"
(for Laravel 3)
Update: For Laravel 4, the file is phpunit.xml
and is found in the root folder. The change is still to set colors="false"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With