saveNewEndpoint() is used by setUp() in test classes as a helper to save a new endpoint
However, it hardcodes the list of resources it sets on the new endpoint. This means that it's useful for most of the test classes in Services module -- but not all. And it's useless for any contrib modules that want to use ServicesWebTestCase as a parent class to test their resources.
I suggest adding a parameter to saveNewEndpoint() which would take an array of resources, eg:
saveNewEndpoint(array('node', 'taxonomy'))
In the function, we add 'system' and 'user' as those are always needed, and then call services_get_resources() to figure out all the sub-components (operations, targeted actions etc) to enable.
Comment | File | Size | Author |
---|---|---|---|
#4 | 2089445-4.services.saveNewEndpoint-parameter.patch | 19.13 KB | joachim |
#2 | 2089445.services.saveNewEndpoint-parameter.patch | 18.75 KB | joachim |
Comments
Comment #1
joachim CreditAttribution: joachim commentedI'll make this into a patch later -- this is just proof of concept code:
This allows callers to just say:
which improves DX a fair bit :)
Comment #2
joachim CreditAttribution: joachim commentedPatch, which is cumulative on #2091169: pointless overrides of populateEndpointFAPI() (and hence will probably fail without that -- or at least cause a notice due to the lack of a 'title' property in the array from populateEndpointFAPI() in the base class).
Comment #4
joachim CreditAttribution: joachim commentedReroll. Should pass, as I've added the 'title' array key in the parent implementation of populateEndpointFAPI().
(Which means #2091169: pointless overrides of populateEndpointFAPI() will need a reroll after this gets in.)
Comment #6
kylebrowning CreditAttribution: kylebrowning commentedIs this still being worked on?
Comment #7
joachim CreditAttribution: joachim commentedI'll try and find time to reroll this. It would make life a lot easier for contrib modules that use Services in their tests.
Comment #8
kylebrowning CreditAttribution: kylebrowning as a volunteer and at Acquia commented