PHP Class Codeception\TestCase\WPAjaxTestCase

Since: 3.4.0
Inheritance: extends WPTestCase
ファイルを表示 Open project: lucatume/wp-browser

Protected Properties

Property Type Description
$_core_actions_get type List of ajax actions called via POST
$_core_actions_post type List of ajax actions called via GET
$_error_level integer Saved error reporting level
$_last_response type Last AJAX response. This is set via echo -or- wp_die.

Public Methods

Method Description
dieHandler ( string $message ) Handler for wp_die() Save the output for analysis, stop execution by throwing an exception.
getDieHandler ( ) : callback Return our callback handler
logout ( ) Clear login cookies, unset the current user
setUp ( ) Set up the test fixture.
setUpBeforeClass ( )
tearDown ( ) Tear down the test fixture.

Protected Methods

Method Description
_handleAjax ( string $action ) Mimic the ajax handling of admin-ajax.php Capture the output via output buffering, and if there is any, store it in $this->_last_message.
_setRole ( string $role ) Switch between user roles E.g. administrator, editor, author, contributor, subscriber

Method Details

_handleAjax() protected method

Mimic the ajax handling of admin-ajax.php Capture the output via output buffering, and if there is any, store it in $this->_last_message.
protected _handleAjax ( string $action )
$action string

_setRole() protected method

Switch between user roles E.g. administrator, editor, author, contributor, subscriber
protected _setRole ( string $role )
$role string

dieHandler() public method

Error conditions (no output, just die) will throw WPAjaxDieStopException( $message ) You can test for this with: $this->setExpectedException( 'WPAjaxDieStopException', 'something contained in $message' ); Normal program termination (wp_die called at then end of output) will throw WPAjaxDieContinueException( $message ) You can test for this with: $this->setExpectedException( 'WPAjaxDieContinueException', 'something contained in $message' );
public dieHandler ( string $message )
$message string

getDieHandler() public method

Return our callback handler
public getDieHandler ( ) : callback
return callback

logout() public method

Clear login cookies, unset the current user
public logout ( )

setUp() public method

Override wp_die(), pretend to be ajax, and suppres E_WARNINGs
public setUp ( )

setUpBeforeClass() public static method

public static setUpBeforeClass ( )

tearDown() public method

Reset $_POST, remove the wp_die() override, restore error reporting
public tearDown ( )

Property Details

$_core_actions_get protected_oe static_oe property

List of ajax actions called via POST
protected static type $_core_actions_get
return type

$_core_actions_post protected_oe static_oe property

List of ajax actions called via GET
protected static type $_core_actions_post
return type

$_error_level protected_oe property

Saved error reporting level
protected int $_error_level
return integer

$_last_response protected_oe property

Last AJAX response. This is set via echo -or- wp_die.
protected type $_last_response
return type