mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Build/Test Tools: Add support for WP_Error in the test suite's wp_die() handlers.
This brings parity with WordPress core `wp_die()` handlers and ensures that if a `WP_Error` object is passed as the `$message` argument to `wp_die()`, the PHPUnit test suite displays the error message correctly. Previously, this would cause a silent fatal error: `Object of class WP_Error could not be converted to string`, leading to just displaying `wp_die called` without any further details. Follow-up to [28797], [41966], [44666], [45160], [47882]. See #55652. git-svn-id: https://develop.svn.wordpress.org/trunk@53634 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d4da924446
commit
3bebac5ea4
@ -152,9 +152,9 @@ function _delete_all_posts() {
|
||||
/**
|
||||
* Handles the WP die handler by outputting the given values as text.
|
||||
*
|
||||
* @param string $message The message.
|
||||
* @param string $title The title.
|
||||
* @param array $args Array with arguments.
|
||||
* @param string|WP_Error $message Error message or WP_Error object.
|
||||
* @param string $title Error title.
|
||||
* @param array $args Arguments passed to wp_die().
|
||||
*/
|
||||
function _wp_die_handler( $message, $title = '', $args = array() ) {
|
||||
if ( ! $GLOBALS['_wp_die_disabled'] ) {
|
||||
@ -199,12 +199,14 @@ function _wp_die_handler_filter_exit() {
|
||||
/**
|
||||
* Dies without an exit.
|
||||
*
|
||||
* @param string $message The message.
|
||||
* @param string $title The title.
|
||||
* @param array $args Array with arguments.
|
||||
* @param string|WP_Error $message Error message or WP_Error object.
|
||||
* @param string $title Error title.
|
||||
* @param array $args Arguments passed to wp_die().
|
||||
*/
|
||||
function _wp_die_handler_txt( $message, $title, $args ) {
|
||||
echo "\nwp_die called\n";
|
||||
list( $message, $title, $args ) = _wp_die_process_input( $message, $title, $args );
|
||||
|
||||
echo "\nwp_die() called\n";
|
||||
echo "Message: $message\n";
|
||||
|
||||
if ( ! empty( $title ) ) {
|
||||
@ -212,9 +214,13 @@ function _wp_die_handler_txt( $message, $title, $args ) {
|
||||
}
|
||||
|
||||
if ( ! empty( $args ) ) {
|
||||
echo "Args: \n";
|
||||
foreach ( $args as $k => $v ) {
|
||||
echo "\t $k : $v\n";
|
||||
echo "Args:\n";
|
||||
foreach ( $args as $key => $value ) {
|
||||
if ( ! is_scalar( $value ) ) {
|
||||
$value = var_export( $value, true );
|
||||
}
|
||||
|
||||
echo "\t$key: $value\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -222,12 +228,14 @@ function _wp_die_handler_txt( $message, $title, $args ) {
|
||||
/**
|
||||
* Dies with an exit.
|
||||
*
|
||||
* @param string $message The message.
|
||||
* @param string $title The title.
|
||||
* @param array $args Array with arguments.
|
||||
* @param string|WP_Error $message Error message or WP_Error object.
|
||||
* @param string $title Error title.
|
||||
* @param array $args Arguments passed to wp_die().
|
||||
*/
|
||||
function _wp_die_handler_exit( $message, $title, $args ) {
|
||||
echo "\nwp_die called\n";
|
||||
list( $message, $title, $args ) = _wp_die_process_input( $message, $title, $args );
|
||||
|
||||
echo "\nwp_die() called\n";
|
||||
echo "Message: $message\n";
|
||||
|
||||
if ( ! empty( $title ) ) {
|
||||
@ -235,11 +243,16 @@ function _wp_die_handler_exit( $message, $title, $args ) {
|
||||
}
|
||||
|
||||
if ( ! empty( $args ) ) {
|
||||
echo "Args: \n";
|
||||
foreach ( $args as $k => $v ) {
|
||||
echo "\t $k : $v\n";
|
||||
echo "Args:\n";
|
||||
foreach ( $args as $key => $value ) {
|
||||
if ( ! is_scalar( $value ) ) {
|
||||
$value = var_export( $value, true );
|
||||
}
|
||||
|
||||
echo "\t$key: $value\n";
|
||||
}
|
||||
}
|
||||
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user