- How do I integrate Symfony PHPUnit Bridge into an existing Laravel test suite?
- Add the package via Composer (`composer require --dev symfony/phpunit-bridge`), then configure it in your `phpunit.xml` or `phpunit.php` to enable deprecation checks. No Laravel-specific changes are needed—it works with Laravel’s default `TestCase` and `phpunit` command. Start with opt-in assertions like `ExpectUserDeprecationMessageTrait` to avoid breaking existing tests.
- Does this package support Laravel’s PHPUnit 9.x or 10.x?
- Yes, use `^7.4` for PHPUnit 9.x (Laravel 9+) and `^8.0` for PHPUnit 10.x (Laravel 10+). The bridge auto-detects your PHPUnit version and provides features like `ClockMock` (PHPUnit 10+) for time-dependent tests. Check compatibility with your Laravel version’s PHPUnit constraints in the [Symfony docs](https://symfony.com/doc/current/components/phpunit_bridge.html).
- Can I fail CI builds if deprecation warnings appear in Laravel tests?
- Yes, configure the bridge to treat deprecations as test failures by extending `DeprecationTestCase` or using the `Deprecation` trait. In CI, set `PHPUNIT_EXIT_CODE_WHEN_TESTS_ARE_DEPRECATED` to `1` in your environment. This integrates seamlessly with Laravel Forge, GitHub Actions, or CircleCI by leveraging PHPUnit’s exit codes.
- Will this slow down my Laravel test suite significantly?
- Deprecation checks add minimal overhead—benchmark with `phpunit --debug` to measure impact. For large suites, cache results or limit checks to critical paths (e.g., feature tests). The bridge is optimized for CI workflows and avoids runtime bloat. Start with a subset of tests to validate performance before full adoption.
- How do I handle existing `@expectedDeprecation` annotations in Laravel tests?
- Migrate to the bridge’s `ExpectUserDeprecationMessageTrait` for modern PHPUnit compatibility. The bridge provides backward-compatible traits to replace old annotations. Run `phpunit --debug` to identify deprecated annotations and update them incrementally. This ensures smooth transitions without breaking existing test logic.
- Does Symfony PHPUnit Bridge work with Laravel’s HttpClient or Symfony components?
- Yes, if your Laravel app uses Symfony components (e.g., `symfony/http-client`), the bridge’s `ClockMock` can mock time-dependent logic in tests. For Laravel’s `Http` facade (which uses Symfony’s `HttpClient`), this enables precise testing of timeouts, retries, or async operations. Check the [Symfony docs](https://symfony.com/doc/current/components/phpunit_bridge.html#clockmock) for component-specific examples.
- Are there alternatives to this package for Laravel deprecation checks?
- Laravel’s native `phpunit` setup supports basic deprecation assertions via `expectDeprecation()`, but lacks CI-friendly filtering and advanced diagnostics. Alternatives like `phpunit/deprecation-detector` are heavier and less integrated with Symfony. This bridge offers a lightweight, Laravel-compatible solution with built-in Symfony synergy, making it ideal for projects using both frameworks.
- How do I configure the bridge to ignore specific deprecation warnings in Laravel?
- Use the `Deprecation` trait’s `ignoreDeprecation()` method or configure a global filter in `phpunit.xml` with `<filter>!path/to/ignored/class.php</filter>`. For Symfony-specific deprecations, extend `DeprecationTestCase` and override `getIgnoredDeprecations()`. This granular control lets you suppress noise while enforcing critical checks.
- Can I use this package in a Laravel project without Symfony components?
- Absolutely. The bridge is framework-agnostic and works purely with PHPUnit. Laravel projects benefit from its deprecation management, test diagnostics, and CI integration regardless of Symfony usage. It’s a drop-in solution for any PHPUnit-based test suite, including Laravel’s default setup.
- What’s the best way to test the bridge’s deprecation checks in a Laravel CI pipeline?
- Add a dedicated test group (e.g., `@DeprecationChecks`) to your `phpunit.xml` and run it separately in CI. Use GitHub Actions’ `phpunit --group DeprecationChecks` or CircleCI’s `phpunit` command with a custom exit code handler. For visibility, configure the bridge to output deprecation details in JUnit format or use annotations for GitHub Actions.