rezzza/mock-extension

This package is abandoned and no longer maintained. No replacement package was suggested.

Mock extension for Behat

Installs: 6 749

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 6

Forks: 4

Open Issues: 3

Type:behat-extension

1.1.1 2015-12-14 15:11 UTC

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

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...