bentools / pest-symfony-kernel
Symfony Kernel and dependency injection for Pest
1.0
2025-06-03 12:19 UTC
Requires
- php: >=8.2
- ext-ctype: *
- ext-iconv: *
- pestphp/pest: ~2.35|~3.0
- symfony/framework-bundle: ~6.4 | ~7.1
Requires (Dev)
- phpstan/phpstan: ^1.11
- symfony/console: ~6.4 | ~7.1
- symfony/dotenv: ~6.4 | ~7.1
- symfony/runtime: ~6.4 | ~7.1
- symfony/yaml: ~6.4 | ~7.1
This package is auto-updated.
Last update: 2025-06-03 12:20:30 UTC
README
Symfony Kernel and dependency injection for Pest PHP.
This library provides a simple way to access the Symfony kernel, container, and services in your Pest tests, making it easier to write integration tests for Symfony applications.
Requirements
- PHP 8.2+
- Pest PHP 2.35+ or 3.0+
- Symfony 6.4+ or 7.x
Installation
composer require --dev bentools/pest-symfony-kernel
Usage
use Symfony\Component\Routing\RouterInterface; use function BenTools\Pest\Symfony\inject; it('injects my router! 🤯', function () { $router = inject(RouterInterface::class); // Fetch router from the service container expect($router)->toBeInstanceOf(RouterInterface::class); // ✨ });
How It Works
This library provides three main functions under the BenTools\Pest\Symfony
namespace:
app()
: Creates and returns a Symfony kernel instance for testingcontainer()
: Gets the test service container from the kernelinject()
: Retrieves a service from the container by its ID
These functions make it easier to work with Symfony's dependency injection container in Pest tests, allowing for simpler access to the application kernel, container, and services.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
MIT.