[wp-trac] [WordPress Trac] #46804: wp-phpunit calls _delete_all_posts() too early during bootstrap

WordPress Trac noreply at wordpress.org
Thu Apr 4 23:55:17 UTC 2019


#46804: wp-phpunit calls _delete_all_posts() too early during bootstrap
----------------------------+-----------------------------
 Reporter:  mynameiskermit  |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  General         |    Version:
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 Bootstrap file looks like so
 {{{#!php
 <?php

 // ...

 _delete_all_posts();

 require dirname( __FILE__ ) . '/testcase.php';
 require dirname( __FILE__ ) . '/testcase-rest-api.php';
 require dirname( __FILE__ ) . '/testcase-rest-controller.php';
 require dirname( __FILE__ ) . '/testcase-rest-post-type-controller.php';
 require dirname( __FILE__ ) . '/testcase-xmlrpc.php';
 require dirname( __FILE__ ) . '/testcase-ajax.php';
 require dirname( __FILE__ ) . '/testcase-canonical.php';
 require dirname( __FILE__ ) . '/exceptions.php';
 require dirname( __FILE__ ) . '/utils.php';
 require dirname( __FILE__ ) . '/spy-rest-server.php';
 }}}

 In one of my mu-plugins, I have a function hooked into before_delete_post
 and wp_trash_post

 {{{#!php
 <?php
 add_action( 'before_delete_post', function() {
     wp_remote_request( ... );
 } );
 }}}

 But since file spy-rest-server.php isn't loaded yet, I can't run test
 units (errors regarding Spy_Server class which does not exist).

 The ''_delete_all_posts()'' should be called AFTER requiring the files

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46804>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list