- What Laravel and PHPUnit versions does this package support?
- The package officially supports Laravel 5.5+ and now aligns with Laravel 13.x. It requires PHPUnit 13, which typically needs PHP 8.2+. Always verify your project’s PHPUnit version for compatibility, especially if using custom test utilities.
- How do I install and set up Laravel Test Assertions in my project?
- Run `composer require --dev jasonmccreary/laravel-test-assertions` and add the `AdditionalAssertions` trait to your base `TestCase` class. This integrates all assertions into your test suite without modifying core Laravel files.
- Can I use this package with PestPHP or other testing frameworks?
- This package is designed for PHPUnit and Laravel’s testing harness. While it won’t conflict with PestPHP, Pest already includes many native assertions, so evaluate whether you need additional Laravel-specific assertions like route or middleware checks.
- What assertions are available for validating FormRequest classes?
- The package provides `assertActionUsesFormRequest()` and `assertRouteUsesFormRequest()` to verify if a controller action or route uses a specific FormRequest for validation. These are useful for ensuring consistent validation logic across your application.
- How do I check if a route uses specific middleware in my tests?
- Use `assertRouteUsesMiddleware()` to verify if a route applies the expected middleware. Pass an array of middleware names and set `exact` to `true` for strict matching, or `false` to check for a subset of middleware.
- Does this package support comparing validation rules in Laravel 13.x?
- Yes, you can use `assertValidationRules()` for subset comparisons or `assertExactValidationRules()` for exact matches. Both methods support rules passed as strings or arrays, making them flexible for Laravel’s updated validation system.
- Will this package work with custom validation rules or Rule objects?
- Yes, the `assertValidationRuleContains()` method checks if a validation rule contains an instance of a custom `Rule` class. This is useful for testing complex validation logic, including custom rules defined in your application.
- How do I test for null values in view data using this package?
- Use `assertViewHasNull($key)` on a `TestResponse` object to verify if a specific key in the view data is explicitly `null`. This is particularly helpful for testing edge cases in your application’s UI logic.
- Are there any performance concerns when using these assertions?
- The package adds minimal overhead, but complex assertions like route or middleware checks may introduce slight delays in test execution. Benchmark critical test suites in your CI pipeline to ensure performance remains acceptable, especially in Laravel 13.x.
- What should I do if I encounter false positives or negatives with Laravel 13.x?
- Test thoroughly in your Laravel 13.x environment, especially for dynamic route registration or middleware changes. If issues arise, check the package’s GitHub issues for known edge cases or consider contributing a fix. Always audit custom test utilities for conflicts with PHPUnit 13.