Opened 9 years ago
Last modified 3 years ago
#35993 new enhancement
Unit tests: XML-RPC Request routines
Reported by: | 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 )
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)
Change History (14)
#3
@
9 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
@
9 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
@
9 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?
#6
@
9 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
@
9 years ago
Great @markoheijnen tks for your attention, and what about the tests? What do you think? Is worthy for this patch?
#8
@
9 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()
,
#10
@
9 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
@
4 years ago
- Description modified (diff)
- Keywords needs-refresh added
- Milestone set to Future Release
This patch needs a refresh.
Related: #20070.
Patch for tests related to XML-Request