- Can I use Symfony’s PHPUnit Bridge in Laravel to catch deprecation warnings from third-party packages?
- Yes, the bridge provides tools like `ExpectUserDeprecationMessageTrait` to explicitly test for deprecation notices, which is especially useful for Laravel projects relying on Symfony-based or legacy packages. It helps surface issues early during CI runs before they break production.
- How do I install this package in a Laravel project?
- Run `composer require symfony/phpunit-bridge` in your project root. No additional Laravel-specific configuration is needed—it integrates directly with PHPUnit’s existing test suite. Just ensure your `phpunit.xml` points to PHPUnit 9.x or 10.x.
- Will this package work with Laravel’s built-in TestCase class?
- Absolutely. The bridge is designed to extend PHPUnit’s core functionality, so it works seamlessly with Laravel’s `TestCase` (which inherits from PHPUnit’s `TestCase`). No changes to your test classes are required unless you want to use its deprecation-specific traits.
- Does Symfony PHPUnit Bridge support Laravel’s ClockMock or DnsMock utilities?
- Yes, the bridge is compatible with Laravel’s mocking utilities like `ClockMock` and `DnsMock`, especially in PHPUnit 10+. These tools are part of PHPUnit’s broader ecosystem, which the bridge enhances without conflicts.
- How does this package handle deprecation notices in CI/CD pipelines?
- The bridge allows you to configure deprecation notices as test failures in CI by leveraging PHPUnit’s assertion system. You can set strictness levels (e.g., fail on warnings) and generate reports, making it ideal for enforcing compatibility during automated testing.
- Is there a performance impact from using this package in Laravel tests?
- The bridge adds minimal overhead, primarily from deprecation capture logic. For most projects, the impact is negligible, but if you’re running performance-critical test suites, benchmark your tests before and after integration to confirm.
- What PHPUnit versions does this package support, and does it work with Laravel 9/10?
- The bridge supports PHPUnit 9.x and 10.x, which aligns perfectly with Laravel 9+ (PHPUnit 9) and Laravel 10+ (PHPUnit 10). Ensure your `composer.json` specifies a compatible PHPUnit version to avoid conflicts.
- Can I use this package to test deprecations in PestPHP instead of PHPUnit?
- While the bridge is designed for PHPUnit, PestPHP (which builds on PHPUnit) can indirectly benefit from its deprecation utilities. However, Pest’s native helpers may suffice for simpler cases. For granular control, stick with PHPUnit’s bridge.
- How do I configure the bridge to ignore specific deprecation notices?
- Use PHPUnit’s built-in configuration or the bridge’s traits to exclude known safe deprecations. For example, you can extend `ExpectUserDeprecationMessageTrait` and override methods to filter out specific messages. Document these exclusions in your CI pipeline.
- Are there any known conflicts with Laravel’s RefreshDatabase trait or other testing utilities?
- The bridge is modular and shouldn’t conflict with Laravel’s testing utilities like `RefreshDatabase`. However, if your tests heavily mock PHPUnit internals (e.g., ReflectionClass), there’s a rare risk of edge cases. Test thoroughly in a staging environment before full adoption.