Closed (outdated)
Project:
Drupal core
Version:
7.x-dev
Component:
simpletest.module
Priority:
Normal
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
22 Nov 2009 at 09:38 UTC
Updated:
3 Jan 2014 at 00:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dries commentedFixing the title.
Comment #2
sunFixing 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.
Comment #3
boombatower commentedAfter 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.
Comment #4
boombatower commentedSuppose this would be more appropriate.
Comment #5
boombatower commentedIf 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.
Comment #6
boombatower commentedFound a bug working on this #875342: Guzzle should pick up X-Drupal-Assertion-* HTTP headers.
Comment #7
boombatower commentedRequires the patch from the issue in #6.
Comment #9
boombatower commentedYep, needs other patch.
Comment #10
fgmRerolled so we can test before judging the intrinsic value.