- Can I use Nette Tester for Laravel unit and integration tests instead of PHPUnit?
- Yes, Nette Tester can replace PHPUnit for unit and integration tests in Laravel, though you’ll need to manually configure Laravel’s service container, HTTP clients, and database transactions. It supports PHP 8.0–8.5, aligning with Laravel’s requirements, and offers parallel execution for faster test suites.
- How do I install Nette Tester in a Laravel project?
- Install via Composer with `composer require nette/tester`. For Laravel, you’ll need to create a custom test runner or CLI script since Nette Tester doesn’t integrate natively with Laravel’s `php artisan test`. Use its CLI tools (e.g., `tester tests/Unit`) for execution.
- Does Nette Tester support Laravel’s database transactions and RefreshDatabase trait?
- Nette Tester lacks native support for Laravel’s `RefreshDatabase` or transaction traits. You’ll need to manually implement database rollbacks in `tearDown()` or use Laravel’s `DatabaseTransactions` trait with custom assertions. Test lifecycle hooks (setUp/tearDown) can help, but verify rollback consistency.
- Will Nette Tester work with Laravel’s HTTP testing (e.g., testing routes, API endpoints)?
- Nette Tester doesn’t have built-in Laravel HTTP helpers like `assertRouteIs(),` but you can use its `Assert::match()` for responses or mock HTTP requests with `PhpInterpreter`. For full Laravel HTTP testing, you’d need to wrap its assertions or use a hybrid approach with Laravel’s `HttpTests`.
- How does Nette Tester handle code coverage in Laravel projects?
- Nette Tester generates coverage reports in CloverXML or HTML formats using Xdebug or PCOV, just like PHPUnit. You can integrate these reports into Laravel’s CI pipelines or tools like `phpunit.xml`. However, ensure your CI environment has the required PHP extensions (e.g., `xdebug`).
- Are there performance benefits to using Nette Tester over PHPUnit in Laravel?
- Nette Tester is comparable in speed to PHPUnit and offers parallel test execution (Windows/Linux), which can significantly speed up large test suites. However, Laravel’s stateful services (e.g., sessions, queues) may require additional isolation to avoid shared-state issues in parallel runs.
- Does Nette Tester support Laravel’s Pest PHP testing framework syntax?
- No, Nette Tester uses its own syntax (e.g., `test()` functions with `Assert::` methods), which differs from Pest’s macros or PHPUnit’s annotations. If your team relies on Pest, you’ll need to rewrite tests or create adapters, though the core assertions are similar.
- How do I mock Laravel’s service container or Eloquent models with Nette Tester?
- Nette Tester provides `PhpInterpreter` and `FileMutator` for mocking files or processes, but Laravel’s service container requires manual setup. Use dependency injection in test classes or mock interfaces directly with `Assert::exception()` or custom assertions. For Eloquent, test models in isolation or use Laravel’s `Mock` facade with wrappers.
- What Laravel versions and PHP versions does Nette Tester support?
- Nette Tester supports PHP 8.0–8.5, which covers Laravel 8.x–11.x. It’s not officially tested with older Laravel versions (e.g., 7.x) or PHP <8.0. Check the [Nette Tester docs](https://github.com/nette/tester) for version-specific notes, especially if using Laravel’s legacy features.
- Are there any CI/CD pitfalls when using Nette Tester with Laravel?
- Nette Tester v2.6.0+ relies on the system `php.ini`, which may cause issues in CI environments with custom PHP settings (e.g., `memory_limit`, `max_execution_time`). Ensure your Docker, Forge, or CI provider (GitHub Actions, CircleCI) has compatible PHP configurations. Test parallel execution carefully to avoid shared-state leaks in Laravel’s queues or sessions.