Make WordPress Core

Opened 8 years ago

Last modified 2 years ago

#35993 new enhancement

Unit tests: XML-RPC Request routines

Reported by: borgesbruno's profile borgesbruno Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 0.71
Component: XML-RPC Keywords: has-patch has-unit-tests dev-feedback needs-refresh
Focuses: Cc:

Description (last modified by desrosj)

I wrote unit tests for the 3 methods regards to XML-RPC request in functions.php, the aim is improve de code coverage, theses methods are:

  • xmlrpc_getposttitle()
  • xmlrpc_getpostcategory()
  • xmlrpc_removepostdata()

This patch cover 100% of coverage related to theses methods above.

Only one thing to consider, I didn't found any XML-RPC format on the WordPress doc with title and category, so I've created a simple XML format with both, following the methods the behaviour is the same.

Attachments (1)

35993.diff (2.5 KB) - added by borgesbruno 8 years ago.
Patch for tests related to XML-Request

Download all attachments as: .zip

Change History (14)

8 years ago

Patch for tests related to XML-Request

#1 @borgesbruno
8 years ago

  • Keywords has-patch has-unit-tests added

#2 @borgesbruno
8 years ago

  • Component changed from HTTP API to General

Please review

Last edited 8 years ago by borgesbruno (previous) (diff)

#3 @johnbillion
8 years ago

  • Component changed from General to XML-RPC
  • Keywords dev-feedback added
  • Milestone changed from Awaiting Review to Future Release

@markoheijnen You're a bit more familiar with XML-RPC than I am. Any feedback on these tests?

#4 @redsweater
8 years ago

I was curious about these methods because they didn't seem familiar even after poking around in WordPress's XMLRPC support for many years. I discovered their use is limited exclusively to the "Blogger" style methods in class-wp-xmlrpc-server.php, specifically "blogger_newPost" and "blogger_editPost".

It seems these are relics possibly from a time before WordPress had formalized processing of the XMLRPC content of requests, parsing them into key/value structs. The methods in question here use a crude regex parsing to extract some key values from the submitted content.

As a code coverage goal for functions.php, it probably makes sense to add tests for these methods. Longer term it seems like they shouldn't really be in functions.php. They make more sense as a cohesive unit with other Blogger API support in class-wp-xmlrpc-server.php. I am not suggesting Blogger API support should be removed, but probably the code should be colocated for easy management and eventual removal some day down the road.

#5 @borgesbruno
8 years ago

Interesting @redsweater, that's explain the reason that I didn't found a good reference about this XMLRPC format with key/value, but I agree with you, for while this patch is useful to code coverage, I've working on this specific file.
Maybe a good approach is create a ticket suggesting in a future release move theses method like you said. Is there a XMLRPC Lead or something like that around?

Last edited 8 years ago by borgesbruno (previous) (diff)

#6 @markoheijnen
8 years ago

I'm kind of a component lead for the XML-RPC. I can look into this on will see what can be done for 4.6. Will come back to you when I got more time.

#7 @borgesbruno
8 years ago

Great @markoheijnen tks for your attention, and what about the tests? What do you think? Is worthy for this patch?

#8 @markoheijnen
8 years ago

I just looked over it and the main thing I wonder is why the usage of global?

The value of _xml_rpc_request_fixture()need to change to just be everything inside the <param>. It grabs the content from param 4 for both function calls.

Also I think it would be best to have content also be included in _xml_rpc_request_fixture() to get the real value of it.
Then in test_xmlrpc_removepostdata() we can just compare xml_rpc_without_post_data with xml_rpc_request_fixture(),

#9 @markoheijnen
8 years ago

Never mind about the global. I see thats the default value of the functions.

#10 @markoheijnen
8 years ago

Material for a new ticket I guess:

I did some research on these functions and they are old. they came from b2 and then the whole XML-RPC was function based. I got this feeling we can just deprecate them and remove the calls. We only need to care about $post_default_title/$post_default_category if we really want to.

$post_default_title feels like a XML-RPC thing.
$post_default_category got replaced with get_option('default_category') in [2681]

#11 @desrosj
4 years ago

  • Description modified (diff)
  • Keywords needs-refresh added
  • Milestone set to Future Release

This patch needs a refresh.

Related: #20070.

#12 @desrosj
4 years ago

  • Version set to 0.71

This ticket was mentioned in Slack in #core-test by pbearne. View the logs.

2 years ago

Note: See TracTickets for help on using tickets.