Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Phpunit Bridge

Phpunit Bridge Laravel Package

symfony/phpunit-bridge

Symfony PHPUnit Bridge adds PHPUnit utilities with a focus on managing and asserting deprecations. It improves test output, helps catch legacy API usage, and eases upgrades by tracking deprecation notices during your test suite runs.

View on GitHub
Deep Wiki
Context7

Provides utilities for PHPUnit, especially user deprecation notices management

Frequently asked questions about Phpunit Bridge
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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai