Skip to content
This repository has been archived by the owner on Nov 29, 2017. It is now read-only.
/ mock-extension Public archive

[Deprecated] Add possibility to define several mock engine for your behat tests

Notifications You must be signed in to change notification settings

rezzza/mock-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Behat Mock Extension

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

About

[Deprecated] Add possibility to define several mock engine for your behat tests

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages