-
Notifications
You must be signed in to change notification settings - Fork 0
PHPUnit
Clio Brichaut edited this page Jan 14, 2023
·
1 revision
"PHPUnit is a programmer-oriented testing framework for PHP." [source]
-
Install the package with
./vendor/bin/sail composer require phpunit/phpunit --dev(in wsl terminal) orcomposer require phpunit/phpunit --dev(in the php container). -
Create the
/app/.env.testingfile containing the details of the testing environment, including the test database:
APP_ENV=testing
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=testing
DB_USERNAME=sail
DB_PASSWORD=password- Use the example tests (in
/app/app/tests/Unit/ExampleTest.phpand/app/app/tests/Feature/ExampleTest.php) to create your tests.
Run the tests with ./vendor/bin/sail artisan test (or an alternative command).
The output should look like this:
| Using the artisan command |
|---|
![]() |
| Using the phpunit command |
|---|
![]() |

