By kuba.zygmunt on
Hi
I'm developing a module which uses twitter module to post tweets on certain account. Trying to develop in TDD way I'm writing bunch of testing functions. Everything was fine until I wanted to test behavior of my function which relies on methods defined in other module.
So is it possible to create a mock module in testing environment, with the same name as an existing one in production env., so when tested module calls
module_load_include('inc', twitter');
it will call my custom file used for testing only ?
Comments
Mock module
The Twitter module implemented a twitter_mock.module that impersonates the Twitter API.
Have a look at how it works and how just by being enabled in a test, Twiter API calls are processed by the local site instead of the external Twitter API.
http://drupalcode.org/project/twitter.git/blob/refs/heads/7.x-3.x:/tests...
http://drupalcode.org/project/twitter.git/blob/refs/heads/7.x-3.x:/tests...