samedi 7 mai 2016

Mocking services when testing with Mink?

I'm working on an application now that has a decent amount of javascript (dynamic forms) that I want to test. I've decided on using PHPUnit Mink + ZombieJS.

I want to mock some services that communicate with external APIs, but I'm not finding any resources on how this can be done with using a testing framework like Mink. If I was using Symfony's built in WebTestCase, I would use a bundle like the (TestDoubleBundle)[http://ift.tt/1UHjO8S], but it won't work for real world requests like those in Mink.

Are there any other solutions available for this? I wonder if the best approach is to create an "test" version of my API service and configure my test environment to load that service instead of the real one. The test service would respond to various API methods with pre-determined responses. The big downside is that it's not as flexible - I can't dynamically configure the expected responses from the API methods.

Aucun commentaire:

Enregistrer un commentaire