Testing
Introduction
Laravel is built with testing in mind. In fact, support for testing with PHPUnit is included out of the box and a phpunit.xml file is already setup for your application. The framework also ships with convenient helper methods that allow you to expressively test your applications.
An ExampleTest.php file is provided in the tests directory. After installing a new Laravel application, simply run phpunit on the command line to run your tests.
Environment
When running tests, Laravel will automatically set the configuration environment to testing. Laravel automatically configures the session and cache to the array driver while testing, meaning no session or cache data will be persisted while testing.
You are free to define other testing environment configuration values as necessary. The testing environment variables may be configured in the phpunit.xml file, but make sure to clear your configuration cache using the config:clear Artisan command before running your tests!
Creating & Running Tests
To create a new test case, use the make:test Artisan command:
1php artisan make:test UserTestThis command will place a new UserTest class within your tests directory. You may then define test methods as you normally would using PHPUnit. To run your tests, simply execute the phpunit command from your terminal:
 1<?php 2  3use Illuminate\Foundation\Testing\WithoutMiddleware; 4use Illuminate\Foundation\Testing\DatabaseMigrations; 5use Illuminate\Foundation\Testing\DatabaseTransactions; 6  7class UserTest extends TestCase 8{ 9    /**10     * A basic test example.11     *12     * @return void13     */14    public function testExample()15    {16        $this->assertTrue(true);17    }18} If you define your own setUp method within a test class, be sure to call parent::setUp.