Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#41915 closed defect (bug) (wontfix)

REST_REQUEST and parse_request in tests

Reported by: drzraf Owned by:
Priority: normal Milestone:
Component: Build/Test Tools Version: 4.8.1
Severity: normal Keywords:
Cc: Focuses: rest-api

Description

I'm testing a method (an API endpoint) making use of REST_REQUEST.
I found that when the test triggers dispatch(), the endpoint is not correctly initialized:
REST_REQUEST is undefined because phpunit didn't go through wp-blog-header.php > WP->main() > WP->parse_request() at which the rest_api_loaded() function is hooked to.

Change History (2)

#1 @rmccue
9 years ago

  • Milestone Awaiting Review
  • Resolutionwontfix
  • Status newclosed

REST_REQUEST should be avoided where possible, because it can only be turned on, not off. We set this only when a request comes in through a request to /wp-json/*, and it's not set in unit tests or when using rest_do_request() internally.

There's no way to set this during tests, and we don't recommend it in any case, so closing this as wontfix.

This ticket was mentioned in Slack in #core-restapi by chrisl27. View the logs.


8 years ago

Note: See TracTickets for help on using tickets.