Allow wp_die()
to die in plain text when running the test suite.
Props jorbin. Fixes #27749. git-svn-id: https://develop.svn.wordpress.org/trunk@28797 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ce3248c482
commit
5c48c4f8a8
@ -47,7 +47,7 @@ if ( "1" == getenv( 'WP_MULTISITE' ) ||
|
|||||||
|
|
||||||
// Override the PHPMailer
|
// Override the PHPMailer
|
||||||
require_once( dirname( __FILE__ ) . '/mock-mailer.php' );
|
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 );
|
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';
|
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.
|
// Preset WordPress options defined in bootstrap file.
|
||||||
// Used to activate themes, plugins, as well as other settings.
|
// Used to activate themes, plugins, as well as other settings.
|
||||||
if(isset($GLOBALS['wp_tests_options'])) {
|
if(isset($GLOBALS['wp_tests_options'])) {
|
||||||
|
@ -70,4 +70,36 @@ class Basic_Object {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Basic_Subclass extends Basic_Object {}
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -302,27 +302,6 @@ function mask_input_value($in, $name='_wpnonce') {
|
|||||||
return preg_replace('@<input([^>]*) name="'.preg_quote($name).'"([^>]*) value="[^>]*" />@', '<input$1 name="'.preg_quote($name).'"$2 value="***" />', $in);
|
return preg_replace('@<input([^>]*) name="'.preg_quote($name).'"([^>]*) value="[^>]*" />@', '<input$1 name="'.preg_quote($name).'"$2 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' ) ) {
|
if ( !function_exists( 'str_getcsv' ) ) {
|
||||||
function str_getcsv( $input, $delimiter = ',', $enclosure = '"', $escape = "\\" ) {
|
function str_getcsv( $input, $delimiter = ',', $enclosure = '"', $escape = "\\" ) {
|
||||||
$fp = fopen( 'php://temp/', 'r+' );
|
$fp = fopen( 'php://temp/', 'r+' );
|
||||||
|
Loading…
Reference in New Issue
Block a user