Download & Extend

Provide assertXmlrpc() function to inspect and verify XML-RPC messages

Project:Drupal core
Version:7.x-dev
Component:simpletest.module
Category:feature request
Priority:normal
Assigned:boombatower
Status:needs work
Issue tags:Needs Documentation

Issue Summary

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

#1

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

Fixing the title.

#2

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.

#3

Assigned to:Anonymous» 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.

#4

Status:closed (won't fix)» needs work

Suppose this would be more appropriate.

#5

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.

#6

#7

Status:needs work» needs review

Requires the patch from the issue in #6.

AttachmentSizeStatusTest resultOperations
639608-assertXmlrpc.patch7.01 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 639608-assertXmlrpc.patch.View details | Re-test

#8

Status:needs review» needs work

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

#9

Yep, needs other patch.

#10

Status:needs work» needs review

Rerolled so we can test before judging the intrinsic value.

AttachmentSizeStatusTest resultOperations
639608-assertXmlrpc-10.patch6.74 KBIdleFAILED: [[SimpleTest]]: [MySQL] 35,954 pass(es), 1 fail(s), and 2 exception(es).View details | Re-test

#11

Status:needs review» needs work

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

nobody click here