Make WordPress Core


Ignore:
Timestamp:
01/05/2020 03:31:10 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve documentation for tests/phpunit/includes/testcase-ajax.php.

Props andizer, SergeyBiryukov.
Fixes #47568.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase-ajax.php

    r46586 r47041  
    11<?php
    2 /**
    3  * Ajax test cases
    4  *
    5  * @package    WordPress
    6  * @subpackage UnitTests
    7  * @since      3.4.0
    8  */
    9 
    102/**
    113 * Ajax test case class
    … …  
    1810
    1911        /**
    20          * Last AJAX response. This is set via echo -or- wp_die.
     12         * Last Ajax response. This is set via echo -or- wp_die.
    2113         *
    2214         * @var string
    … …  
    2517
    2618        /**
    27          * List of ajax actions called via GET
     19         * List of Ajax actions called via GET.
    2820         *
    2921         * @var array
    … …  
    4133
    4234        /**
    43          * Saved error reporting level
     35         * Saved error reporting level.
    4436         *
    4537         * @var int
    … …  
    4840
    4941        /**
    50          * List of ajax actions called via POST
     42         * List of Ajax actions called via POST.
    5143         *
    5244         * @var array
    … …  
    140132
    141133        /**
    142          * Set up the test fixture.
    143          * Override wp_die(), pretend to be ajax, and suppress E_WARNINGs
     134         * Sets up the test fixture.
     135         *
     136         * Overrides wp_die(), pretends to be Ajax, and suppresses E_WARNINGs.
    144137         */
    145138        public function setUp() {
    … …  
    163156
    164157        /**
    165          * Tear down the test fixture.
    166          * Reset $_POST, remove the wp_die() override, restore error reporting
     158         * Tears down the test fixture.
     159         *
     160         * Resets $_POST, removes the wp_die() override, restores error reporting.
    167161         */
    168162        public function tearDown() {
    … …  
    179173
    180174        /**
    181          * Clear login cookies, unset the current user
     175         * Clears login cookies, unsets the current user.
    182176         */
    183177        public function logout() {
    … …  
    190184
    191185        /**
    192          * Return our callback handler
     186         * Returns our callback handler
    193187         *
    194188         * @return callback
    … …  
    199193
    200194        /**
    201          * Handler for wp_die()
     195         * Handler for wp_die().
     196         *
    202197         * Save the output for analysis, stop execution by throwing an exception.
     198         *
    203199         * Error conditions (no output, just die) will throw <code>WPAjaxDieStopException( $message )</code>
    204200         * You can test for this with:
    … …  
    212208         * </code>
    213209         *
    214          * @param string $message
     210         * @param string $message The message to set.
     211         *
     212         * @throws WPAjaxDieStopException     Thrown to stop further execution.
     213         * @throws WPAjaxDieContinueException Thrown to stop execution of the Ajax function,
     214         *                                    but continue the unit test.
    215215         */
    216216        public function dieHandler( $message ) {
    … …  
    229229
    230230        /**
    231          * Switch between user roles
    232          * E.g. administrator, editor, author, contributor, subscriber
    233          *
    234          * @param string $role
     231         * Switches between user roles.
     232         *
     233         * E.g. administrator, editor, author, contributor, subscriber.
     234         *
     235         * @param string $role The role to set.
    235236         */
    236237        protected function _setRole( $role ) {
    … …  
    242243
    243244        /**
    244          * Mimic the ajax handling of admin-ajax.php
    245          * Capture the output via output buffering, and if there is any, store
    246          * it in $this->_last_response.
    247          *
    248          * @param string $action
     245         * Mimics the Ajax handling of admin-ajax.php.
     246         *
     247         * Captures the output via output buffering, and if there is any,
     248         * stores it in $this->_last_response.
     249         *
     250         * @param string $action The action to handle.
    249251         */
    250252        protected function _handleAjax( $action ) {
Note: See TracChangeset for help on using the changeset viewer.