[wp-trac] [WordPress Trac] #50366: WordPress rest_api_init action doesn't work in PHPUnit tests

WordPress Trac noreply at wordpress.org
Thu Jun 11 14:07:44 UTC 2020


#50366: WordPress rest_api_init action doesn't work in PHPUnit tests
--------------------------+-------------------------
 Reporter:  skarabeq      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  REST API      |     Version:  5.4.2
 Severity:  normal        |  Resolution:  worksforme
 Keywords:                |     Focuses:
--------------------------+-------------------------
Changes (by TimothyBlynJacobs):

 * status:  reopened => closed
 * resolution:   => worksforme


Comment:

 @skarabeq you are receiving that message because you are running unit
 tests. The test runner expects no incorrect usage notices to occur, but
 one did occur for the `register_rest_route` function. The test runner
 suppresses the normal error trigger so that it can be unit testable. If
 you run your code outside of PHPUnit you'll see the full `_doing_it_wrong`
 error.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50366#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list