Merge pull request #25 from kristianwind/smoke-rest-namespace
Assert the REST namespace by name, not against its own constant
This commit is contained in:
@@ -211,6 +211,18 @@ $ours = array_filter(
|
|||||||
);
|
);
|
||||||
wc_edm_ok( 'the REST routes are registered', count( $ours ) > 0, 'namespace ' . WC_EDM_REST_API::REST_NAMESPACE );
|
wc_edm_ok( 'the REST routes are registered', count( $ours ) > 0, 'namespace ' . WC_EDM_REST_API::REST_NAMESPACE );
|
||||||
|
|
||||||
|
// The namespace spelled out, NOT compared to the constant it came from. The
|
||||||
|
// filter above derives what it looks for from REST_NAMESPACE, so it agrees
|
||||||
|
// with itself whatever that constant says: rename it and the routes are still
|
||||||
|
// "registered", while every caller that already integrated against
|
||||||
|
// wc-edm/v1 gets a 404 and nothing here goes red. This is the one string in
|
||||||
|
// the plugin that somebody else's code depends on by name.
|
||||||
|
wc_edm_is(
|
||||||
|
'and under the namespace callers already integrated against',
|
||||||
|
'wc-edm/v1',
|
||||||
|
WC_EDM_REST_API::REST_NAMESPACE
|
||||||
|
);
|
||||||
|
|
||||||
$request = new WP_REST_Request( 'GET', '/' . WC_EDM_REST_API::REST_NAMESPACE . '/groups' );
|
$request = new WP_REST_Request( 'GET', '/' . WC_EDM_REST_API::REST_NAMESPACE . '/groups' );
|
||||||
$response = rest_get_server()->dispatch( $request );
|
$response = rest_get_server()->dispatch( $request );
|
||||||
wc_edm_is( 'and they refuse an unauthenticated caller', 401, $response->get_status() );
|
wc_edm_is( 'and they refuse an unauthenticated caller', 401, $response->get_status() );
|
||||||
|
|||||||
Reference in New Issue
Block a user