开发者

How to specify a web service URL within a Drupal module's simpletest?

I have a开发者_StackOverflow Drupal module that talks to a REST API on a separate server for user registration and authentication. The module runs on multiple sites which point to different servers which may run different versions of the REST API.

Ideally, I'd like to be able to run each site against its own end-point, in case changes on the back end break things. Is there a way to dynamically specify a different end-point URL when running a test? Or do I have to edit the .test file for each site?

I'm trying to keep the module's files as generic and flexible as possible. I guess I could have the .test file look for a .inc file that could override the URL, if needed for a particular site. Is there a better way though?


You can use a variable, using variable_get, and define the site url in settings.php, using a $conf override:

In the .test file: variable_get('endpoint_url', NULL); and in settings.php: $conf['endpoint_url'] = 'http://foo/bar';. That way, for each site, you need only edit settings.php.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜