• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress develop tests

WordPress develop tests

WordPress develop tests a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / WP_Ajax_UnitTestCase::dieHandler() – Handler for wp_die() Save the output for analysis, stop execution by throwing an exception.

You appear to be a bot. Output may be restricted

Description

Handler for wp_die().

Save the output for analysis, stop execution by throwing an exception. Error conditions (no output, just die) will throw <code>WPAjaxDieStopException( $message )</code>. You can test for this with: <code> $this->expectException( 'WPAjaxDieStopException' ); $this->expectExceptionMessage( 'something contained in $message' ); </code> Normal program termination (wp_die called at the end of output) will throw <code>WPAjaxDieContinueException( $message )</code>. You can test for this with: <code> $this->expectException( 'WPAjaxDieContinueException' ); $this->expectExceptionMessage( 'something contained in $message' ); </code>

Usage

WP_Ajax_UnitTestCase::dieHandler( $message );

Parameters

$message
( string ) required – The message to set.

Returns

void

Source

File name: wordpress-develop-tests/phpunit/includes/testcase-ajax.php
Lines:

1 to 13 of 13
  public function dieHandler( $message ) {
    $this->_last_response .= ob_get_clean();

    if ( '' === $this->_last_response ) {
      if ( is_scalar( $message ) ) {
        throw new WPAjaxDieStopException( (string) $message );
      } else {
        throw new WPAjaxDieStopException( '0' );
      }
    } else {
      throw new WPAjaxDieContinueException( $message );
    }
  }
 

 View on GitHub

Published: 26th November 2019 | Last updated: 27th November 2019

Primary Sidebar

Information

Function name: WP_Ajax_UnitTestCase::dieHandler
Class ref: WP_Ajax_UnitTestCase
Plugin ref: WordPress develop tests
Version: 5.9.3
Sourcefile: phpunit/includes/testcase-ajax.php
File ref: phpunit/includes/testcase-ajax.php
Deprecated?: No
API Letters: A,D,U,W

Footer

WordPress develop tests
WordPress develop tests
WordPress develop tests a2z
WordPress 6.4.1
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  develop.wp-a2z.org
© Copyright WordPress develop tests 2014-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites