diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php
index 8bf1a4fcb8..885e148639 100644
--- a/tests/phpunit/includes/bootstrap.php
+++ b/tests/phpunit/includes/bootstrap.php
@@ -47,7 +47,7 @@ if ( "1" == getenv( 'WP_MULTISITE' ) ||
// Override the PHPMailer
require_once( dirname( __FILE__ ) . '/mock-mailer.php' );
-$phpmailer = new MockPHPMailer();
+$phpmailer = new MockPHPMailer();
system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/install.php' ) . ' ' . escapeshellarg( $config_file_path ) . ' ' . $multisite );
@@ -67,6 +67,10 @@ unset( $multisite );
require_once dirname( __FILE__ ) . '/functions.php';
+$GLOBALS['_wp_die_disabled'] = false;
+// Allow tests to override wp_die
+tests_add_filter( 'wp_die_handler', '_wp_die_handler_filter' );
+
// Preset WordPress options defined in bootstrap file.
// Used to activate themes, plugins, as well as other settings.
if(isset($GLOBALS['wp_tests_options'])) {
diff --git a/tests/phpunit/includes/functions.php b/tests/phpunit/includes/functions.php
index 0b24a8e638..e8d30cb0c1 100644
--- a/tests/phpunit/includes/functions.php
+++ b/tests/phpunit/includes/functions.php
@@ -70,4 +70,36 @@ class Basic_Object {
}
}
-class Basic_Subclass extends Basic_Object {}
\ No newline at end of file
+class Basic_Subclass extends Basic_Object {}
+
+function _wp_die_handler( $message, $title = '', $args = array() ) {
+ if ( !$GLOBALS['_wp_die_disabled'] ) {
+ _wp_die_handler_txt( $message, $title, $args);
+ } else {
+ //Ignore at our peril
+ }
+}
+
+function _disable_wp_die() {
+ $GLOBALS['_wp_die_disabled'] = true;
+}
+
+function _enable_wp_die() {
+ $GLOBALS['_wp_die_disabled'] = false;
+}
+
+function _wp_die_handler_filter() {
+ return '_wp_die_handler';
+}
+
+function _wp_die_handler_txt( $message, $title, $args ) {
+ echo "\nwp_die called\n";
+ echo "Message : $message\n";
+ echo "Title : $title\n";
+ if ( ! empty( $args ) ) {
+ echo "Args: \n";
+ foreach( $args as $k => $v ){
+ echo "\t $k : $v\n";
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/phpunit/includes/utils.php b/tests/phpunit/includes/utils.php
index f39d7eecff..ae8abe7678 100644
--- a/tests/phpunit/includes/utils.php
+++ b/tests/phpunit/includes/utils.php
@@ -302,27 +302,6 @@ function mask_input_value($in, $name='_wpnonce') {
return preg_replace('@]*) name="'.preg_quote($name).'"([^>]*) value="[^>]*" />@', '', $in);
}
-$GLOBALS['_wp_die_disabled'] = false;
-function _wp_die_handler( $message, $title = '', $args = array() ) {
- if ( !$GLOBALS['_wp_die_disabled'] ) {
- _default_wp_die_handler( $message, $title, $args );
- } else {
- //Ignore at our peril
- }
-}
-
-function _disable_wp_die() {
- $GLOBALS['_wp_die_disabled'] = true;
-}
-
-function _enable_wp_die() {
- $GLOBALS['_wp_die_disabled'] = false;
-}
-
-function _wp_die_handler_filter() {
- return '_wp_die_handler';
-}
-
if ( !function_exists( 'str_getcsv' ) ) {
function str_getcsv( $input, $delimiter = ',', $enclosure = '"', $escape = "\\" ) {
$fp = fopen( 'php://temp/', 'r+' );