Extend the simpletest framework, and by extension the XML-RPC backend, with an assertXmlrpc() function similar to assertMail(). The function would allow tests to inspect the outgoing XML-RPC messages. This would be very useful for modules like Mollom -- see this related issue: #245682: Enable use of Mollom for any form.

Comments

dries’s picture

Title: Provide an assertXmlrpc() to inspect and verify XML-RPC message » Provide assertXmlrpc() function to inspect and verify XML-RPC messages

Fixing the title.

sun’s picture

Component: xml-rpc system » simpletest.module

Fixing component.

First step would be to stuff some drupal_alter()s and hook invocations into

- http://api.drupal.org/api/function/xmlrpc_server/7
- http://api.drupal.org/api/function/_xmlrpc/7

heh, both are mostly unchanged since Drupal 4.7... :)

uhm. "mostly"? Entirely, it seems.

boombatower’s picture

Assigned: Unassigned » boombatower
Status: Active » Closed (won't fix)

After ponding this with my PIFR tests and I finally implemented a test for PIFT. During the writing of the test I realized that XML-RPC does not fit the mold like assertMail() does. It would be rather difficult to properly test XML-RPC without being able to specified responses and such which would require a somewhat large API within SimpleTest. Since XML-RPC already provides everything we need it seems that is the best solution, mock modules ftw.

What I did was create pifr_xmlrpc in the tests directory of PIFT. The module implements the portion of the XML-RPC API that PIFT interacts with. I then enable the module during testing and implement a rudimentary version of the API that provides easy to test results.

For example the API returns the test IDs assigned to tests...the pifr_xmlrpc implementation simply starts from 1 and counts up every time. This makes it easy to create assertions based on that.

I also simulate a test result retrieval by allowing my test to set the XML-RPC response for the related method.

The main benefit of this over straight calling of the XML-RPC methods is that you can simular all conditions around the XML-RPC calls, like cron being the mechanism to start the XML-RPC. My current PIFR tests simply invoke some XML-RPC calls manually, but obviously this is a better way of testing them.

Considering the numerous ways an XML-RPC API may be used and the simplicity of the PIFT mock module I think we should document this as the official way for testing XML-RPC. Take a look:

I will be writing a test for PIFR XML-RPC in the near future.

boombatower’s picture

Status: Closed (won't fix) » Needs work
Issue tags: +Needs documentation

Suppose this would be more appropriate.

boombatower’s picture

If anything do we want core testing system to come with pifr_xmlrpc_call() and _clear() type functions kinda like SimpleTest has for storing e-mail? That and we could hook into the XML-RPC system so that the testing system automatically catches all the responses instead of sending them out...many times you'll still need to make mock module to run against.

boombatower’s picture

boombatower’s picture

Status: Needs work » Needs review
StatusFileSize
new7.01 KB

Requires the patch from the issue in #6.

Status: Needs review » Needs work

The last submitted patch, 639608-assertXmlrpc.patch, failed testing.

boombatower’s picture

Yep, needs other patch.

fgm’s picture

Status: Needs work » Needs review
StatusFileSize
new6.74 KB

Rerolled so we can test before judging the intrinsic value.

Status: Needs review » Needs work
Issue tags: -Needs documentation

The last submitted patch, 639608-assertXmlrpc-10.patch, failed testing.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.