- Can I use this module to test a Laravel app that uses Symfony components (e.g., Mailer, HTTP Client)?
- Yes, this module works well for Laravel apps leveraging Symfony components. You’ll need to bootstrap the Symfony Kernel (e.g., via `symfony/http-kernel`) and configure Codeception to load it. Assertions like `assertEmailSent()` or `seeEventTriggered()` will work for Symfony-powered features while keeping Laravel’s native testing tools for Eloquent/Route tests.
- What Laravel versions or Symfony components does this module support?
- This module is Symfony-focused (6.4–8.0) and requires Codeception 5+ (PHP 8.2+). While Laravel itself isn’t supported, it integrates seamlessly with Symfony components like HTTP Client, Mailer, or Validator. For Laravel 10+, ensure your Symfony components are compatible with PHP 8.2+ and pin versions in `composer.json` to avoid conflicts.
- How do I set up this module in a Laravel project?
- Install via Composer: `composer require codeception/module-symfony`. Configure `codeception.yml` to extend the Symfony module, then create a test suite (e.g., `symfony` for API/CLI tests). Bootstrap the Symfony Kernel in `tests/_bootstrap.php` or via `setUp()` in your test classes. Laravel’s `.env.testing` will auto-load if present.
- Will this module work for UI testing like Laravel Dusk?
- No, this module is optimized for API/CLI/functional testing (e.g., HTTP requests, service assertions). For UI testing, use Laravel Dusk or Codeception’s WebDriver module. However, you can combine both: use this module for Symfony-powered API tests and Dusk for frontend interactions, but avoid mixing WebDriver in the same suite to prevent conflicts.
- How do I test Symfony events or services in Laravel with this module?
- Use assertions like `seeEventTriggered('event.name')` or access services via `$I->grabService('service_id')`. For Laravel apps, wrap Symfony services in a container-compatible class or use `symfony/dependency-injection` to bridge gaps. Example: `$I->seeEventTriggered('kernel.request')` verifies event dispatching in your Symfony-integrated Laravel routes.
- Are there performance concerns with bootstrapping the Symfony Kernel in tests?
- Yes, Kernel bootstrapping can slow tests. Mitigate this by caching the Kernel instance (e.g., in a test trait) or using `reset()` sparingly. For Laravel, consider lazy-loading the Kernel only when needed (e.g., in `setUpBeforeClass()`) or mocking it for unit tests. Profile with `codecept run --debug` to identify bottlenecks.
- Can I use this module alongside Laravel’s built-in testing tools (e.g., HttpTests, Pest)?
- Absolutely. Use this module for Symfony-specific features (e.g., Mailer, Events) and Laravel’s tools for Eloquent/Route tests. For Pest, create custom helpers using this module’s traits (e.g., `NotifierAssertionsTrait`). Example: Combine `assertRouteIsValid()` (Laravel) with `assertEmailSent()` (Symfony module) in the same test suite.
- What if my Laravel app uses Symfony 5.x? Will this module work?
- No, the latest version (v3.x) supports Symfony 6.4–8.0. For Symfony 5.x, use the deprecated `v2.x` branch, but it’s unsupported. Upgrade your Symfony components or consider alternatives like custom Pest helpers. Check compatibility with `composer why-not symfony/symfony ^6.4` to plan migrations.
- How do I write custom assertions for Symfony features not covered by this module?
- Extend the module using traits like `NotifierAssertionsTrait`. Create a custom trait in your test suite (e.g., `CustomSymfonyAssertions`) and include it in your test classes. Example: Add `assertDeprecationTriggered()` by inspecting Symfony’s `DebugClassLoader` logs. Document these in your test suite’s README.
- What are the alternatives to this module for testing Symfony components in Laravel?
- For lightweight testing, use Pest with custom Symfony helpers (e.g., `SymfonyTestHelper`). For full-stack testing, consider Laravel’s `HttpTests` (API) or Dusk (UI), but they lack Symfony-specific assertions. If you’re using API Platform, its built-in test tools may suffice. This module is ideal if you need deep Symfony integration without rewriting assertions.