Make WordPress Core

Opened 6 years ago

Last modified 6 years ago

#46804 new defect (bug)

wp-phpunit calls _delete_all_posts() too early during bootstrap

Reported by: mynameiskermit's profile mynameiskermit Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords:
Focuses: Cc:

Description

Bootstrap file looks like so

<?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
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

Change History (1)

#1 @SergeyBiryukov
6 years ago

  • Component changed from General to Build/Test Tools
Note: See TracTickets for help on using tickets.