Environment: Symfony2, Guzzle
Problem: I want to write functional tests and replace the guzzle client used in the tested class with a mock client class sometimes.
In detail:
- class BookFetcher uses class ApiConnector which uses Guzzle to retrieve the data from somewhere else
- I want to write some tests which actually use the original ApiConnector to make sure that nothing has been changed at the other side
- as this is slow I want to mock the ApiConnector in all other tests using a mock class
- At the moment I replace the ApiConnector class with a MockClass in config_test.yml (parameters section). This affects ALL tests (no more contract testing).
- I need a way to replace the ApiConnector class with my mock class sometimes