WP_Ajax_UnitTestCase::_handleAjax PHP Method

_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_response.
protected _handleAjax ( string $action )
$action string
    protected function _handleAjax($action)
    {
        // Start output buffering
        ini_set('implicit_flush', false);
        ob_start();
        // Build the request
        $_POST['action'] = $action;
        $_GET['action'] = $action;
        $_REQUEST = array_merge($_POST, $_GET);
        // Call the hooks
        do_action('admin_init');
        do_action('wp_ajax_' . $_REQUEST['action'], null);
        // Save the output
        $buffer = ob_get_clean();
        if (!empty($buffer)) {
            $this->_last_response = $buffer;
        }
    }