Testing
Database setup
Use an in-memory, sqlite database for speed of testing. Add environment variables to phpunit.xml:
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
Creating tests
Test files are expected to have the suffix Test.php. If they do not have this suffix, no tests will run.
Tests must either have an @test doc-block entry, or the name of the test must begin with test_ for PHPUnit to run them. We prefer the doc-block entry.
Running tests
You can run the whole test suite by running vendor/bin/phpunit. Laravel Homestead includes a phpunit shortcut you can use instead.
Limit the test that you run with --filter. Note that it will match anything that begins with the argument you pass, so you can end up running multiple tests from different files and directories if you use very generic names for your tests.
phpunit --filter the_name_of_the_test
phpunit --filter ClassOfTest
Run just a specific file:
phpunit ./tests/Unit/TestFile