- Can I use drjele/symfony-phpunit directly in a Laravel project?
- No, this package is designed for Symfony and won’t integrate natively with Laravel’s testing tools. It relies on Symfony’s Kernel, WebTestCase, and container, which are incompatible with Laravel’s TestCase or Http::fake(). Use it only if your project explicitly bridges Symfony components.
- What Laravel alternatives exist for Symfony’s test helpers?
- Laravel provides built-in tools like `TestCase`, `Http::fake()`, and `RefreshDatabase()` for testing. For advanced needs, consider `laravel/testbench` (for legacy testing) or `spatie/laravel-test-factories` for cleaner test data setup. These are fully Laravel-compatible.
- How do I install drjele/symfony-phpunit in a Laravel project?
- Run `composer require drjele/symfony-phpunit --dev` to add it as a development dependency. However, avoid relying on its core features—use it only to extract reusable utilities (e.g., assertion methods) and rewrite them for Laravel’s ecosystem.
- Does this package support PHPUnit 10.x and Laravel’s testing stack?
- The package works with PHPUnit 10.x, but its Symfony-specific abstractions (e.g., `WebTestCase`) won’t integrate with Laravel’s `TestCase`. You’d need to manually adapt its helpers or create a wrapper package to bridge the gap.
- Can I reuse Symfony’s Client or BrowserKit in Laravel tests?
- Yes, if your project uses Symfony’s HTTP Client or Process Component, you can manually leverage parts of this package (e.g., `Client::create()`). However, Laravel’s `Http::fake()` or `Pest` (a modern alternative) often provide simpler solutions for HTTP testing.
- What’s the risk of adding Symfony dependencies to a Laravel project?
- Adding this package could bloat your project with Symfony’s dependencies (e.g., `browser-kit`, `css-selector`). Over time, maintaining Symfony-specific code in a Laravel app may introduce friction, especially if Laravel’s testing tools evolve differently.
- How do I adapt Symfony’s test utilities for Laravel?
- Extract reusable parts (e.g., assertion methods) and rewrite them as Laravel traits or helpers. For example, convert Symfony’s `assertResponseStatusCode()` into a trait for Laravel’s `TestCase`. Avoid direct dependency on Symfony’s test layer.
- Is there a Laravel package that wraps drjele/symfony-phpunit?
- No official wrapper exists, but you could create one by depending on this package and exposing Laravel-friendly facades or traits. This would reduce integration effort but requires maintenance to handle Symfony-Laravel compatibility gaps.
- Should I fork this package for Laravel use?
- Forking is risky due to Symfony’s evolving assumptions (e.g., container access). Instead, audit your Laravel tests for pain points, then either adapt specific utilities or invest in a custom solution using Laravel’s native tools or Pest.
- What’s the best approach for mixed Symfony-Laravel test projects?
- If your project uses both stacks, isolate Symfony-specific tests in a separate module or use a monorepo structure. For shared utilities, create a neutral package (e.g., `vendor/test-utils`) that both Laravel and Symfony can consume without tight coupling.