PHP Testing
PHP testing uses PHPUnit (unit/integration), Pest (expressive syntax), and Laravel's built-in test helpers. Tests catch regressions and document expected behaviour.
PHP testing uses PHPUnit (unit/integration), Pest (expressive syntax), and Laravel's built-in test helpers. Tests catch regressions and document expected behaviour.
# Install PHPUnit
composer require --dev phpunit/phpunit
# Or Pest (recommended for new projects)
composer require --dev pestphp/pest
# Run tests
php artisan test # Laravel
./vendor/bin/pest # Pest
./vendor/bin/phpunit # PHPUnit
Pest provides a fluent, Jest-like API over PHPUnit — compatible with all PHPUnit assertions.