rezzza / mock-extension
Mock extension for Behat
Installs: 6 748
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 6
Forks: 4
Open Issues: 3
Type:behat-extension
Requires
- php: >=5.3.2
- atoum/atoum: ~1.0|~2.0
- behat/behat: ~3.0
- behat/symfony2-extension: ~2.0
This package is not auto-updated.
Last update: 2022-02-01 12:37:42 UTC
README
DEPRECATED We no longer provide support for this extension. Feel free to fork.
Let the mock engine that you want coming to help you in your behat tests by mocking the Symfony services.
- dev-master : Behat 2.5.x
- dev-behat3 : Behat 3.0.x
Adapters
- Atoum : https://github.com/atoum/atoum
Setup
1 - Declare to use the extension in your behat.yml
default: extensions: Rezzza\MockExtension\Extension: ~
2 - Implements Rezzza\MockExtension\MockAware
interface on your context.
3 - Override AppKernel::getContainerBaseClass
protected function getContainerBaseClass() { if ('test' == $this->environment) { return 'Rezzza\MockExtension\MockContainer'; } return parent::getContainerBaseClass(); }
Usage
In your context create mock for your services :
use Rezzza\MockExtension\Adapter\AtoumAdapter; $mockGoutte = $this->mocker->mockService( 'my.goutte_client', new AtoumAdapter('\Behat\Mink\Driver\Goutte\Client') );
Then follow the instructions of your mock engine to use the result
Contribute
If you want to see your prefered mock engine, you can make a PR by creation the adapter.
It just needs to follow Rezzza\MockExtension\MockEngine
interface.
Credit
Initial concept come from : https://github.com/PolishSymfonyCommunity/Symfony2MockerExtension
but Mockery drives me crazy...