This issue is part of a set listed at #1342664: Testing Roadmap

Based on this Mock Web Service for Simpletest, change the Twitter API host that is located at class Twitter->$host (I am not sure about the best way to achieve this) so calls get piped to a local Mock web service.

Comments

AlessMascherpa’s picture

I found those post that might be helpful:
- Testing using mock module I guy trying to do the same as (or similar to) what we are trying to do in the Twitter DrupalContribute.
- #785362: Create more extensive guidelines for "mock module" creation and style
- #786156: Update the SimpleTest tutorial to reflect the 'mock module' pattern.

I also recommend to check the Services module. Not only because its a good example on how to do this with a mock module (see tests dir of the module), despite it does in other way that the one presented in Mock Web Service for Simpletest, also because it could be good to use its API to interact with other systems. As a matter of fact, its 4th version is going to be the starting point of web services API in core of D8 (read: http://www.garfieldtech.com/blog/web-services-initiative ("The road ahead" point)). This last point might be more appropriate in future versions of Twitter module.

Cheers,
Alessandro Mascherpa.

juampynr’s picture

Now it is very easy to change the host: http://drupal.org/node/1346790#comment-5293692

It is time to focus in the mock server.

juampynr’s picture

Added a test suite to test actions where Twitter uses Oauth (ie. pulling tweets, posting and signing in).

A mock server has been added as a submodule within the tests directory and a dummy call was made to it with success. The next step is to see how to simulate an account addition with this.

http://drupalcode.org/project/twitter.git/commitdiff/ce72c50c05b5d03857f...

juampynr’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev

Moved to 7.x branch.

juampynr’s picture

Status: Active » Fixed

Changed from Singleton to Drupal variables. Now the mock class can change hostnames to simulate the Twitter API.

http://drupalcode.org/project/twitter.git/commitdiff/6783e46
http://drupalcode.org/project/twitter.git/commitdiff/21683a9

Automatically closed -- issue fixed for 2 weeks with no activity.