Mock Symfony service in Behat functional test

What is the best and correct way to mock a Symfony Service using Behat and kerneldriver suite?

I have a Service that performs external API calls and I need to mock it to improve test performances and to get fake data to drive my tests.

I know I cannot replace a container service at runtime because the container is compiled, and I do not want to change the Service class for test environment because the mocked service should return different data in each scenario.

Any advice would be really appreciated, thank you.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *