Download the PHP package polishsymfonycommunity/symfony-mocker-container without Composer
On this page you can find all versions of the php package polishsymfonycommunity/symfony-mocker-container. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download polishsymfonycommunity/symfony-mocker-container
More information about polishsymfonycommunity/symfony-mocker-container
Files in polishsymfonycommunity/symfony-mocker-container
Package symfony-mocker-container
Short Description Provides base Symfony dependency injection container enabling service mocking.
License MIT
Homepage http://symfonylab.pl
Informations about the package symfony-mocker-container
Symfony Mocker Container
Mocker container enables you to mock services in the Symfony dependency injection container. It is particularly useful in functional tests and Behat scenarios.
This package was always a hack. For a better approach try https://github.com/docteurklein/TestDoubleBundle.
If you want to use the mocker container with Behat try the Symfony2 Mocker Extension.
Warning:
Mind that you can only mock services using the BrowserKitDriver (used with Symfony2 functional tests and Symfony2Extension for Behat). You won't be able to mock services using any driver that makes actual HTTP request to your applicaction.
Installation
Add SymfonyMockerContainer to your composer.json:
Replace base container class for test environment in app/AppKernel.php
::
Clear your cache.
Using in Behat steps
Use mock()
method on the container to create a new Mock with Mockery:
Once service is mocked the container will return its mock instead of a real service.
Using in Symfony functional tests
All versions of symfony-mocker-container with dependencies
symfony/dependency-injection Version ^4.3 || ^5.0 || ^6.0 || ^7.0
mockery/mockery Version ^1.3