Changeset 47041
- Timestamp:
- 01/05/2020 03:31:10 PM (5 years ago)
- Location:
- trunk/tests/phpunit/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/exceptions.php
r46586 r47041 6 6 7 7 /** 8 * General exception for wp_die() 8 * General exception for wp_die(). 9 9 */ 10 10 class WPDieException extends Exception {} 11 11 12 12 /** 13 * Exception for cases of wp_die(), for ajax tests. 14 * This means there was an error (no output, and a call to wp_die) 13 * Exception for cases of wp_die(), for Ajax tests. 14 * 15 * This means there was an error (no output, and a call to wp_die). 15 16 * 16 17 * @package WordPress … … 21 22 22 23 /** 23 * Exception for cases of wp_die(), for ajax tests.24 * This means execution of the ajax function should be halted, but the unit25 * test can continue. The function finished normally and there was not an26 * error (output happened, but wp_die was called to end execution) This is27 * used with WP_Ajax_Response::send24 * Exception for cases of wp_die(), for Ajax tests. 25 * 26 * This means the execution of the Ajax function should be halted, but the unit test 27 * can continue. The function finished normally and there was no error (output happened, 28 * but wp_die was called to end execution). This is used with WP_Ajax_Response::send(). 28 29 * 29 30 * @package WordPress -
trunk/tests/phpunit/includes/testcase-ajax.php
r46586 r47041 1 1 <?php 2 /**3 * Ajax test cases4 *5 * @package WordPress6 * @subpackage UnitTests7 * @since 3.4.08 */9 10 2 /** 11 3 * Ajax test case class … … 18 10 19 11 /** 20 * Last A JAX response.This is set via echo -or- wp_die.12 * Last Ajax response. This is set via echo -or- wp_die. 21 13 * 22 14 * @var string … … 25 17 26 18 /** 27 * List of ajax actions called via GET19 * List of Ajax actions called via GET. 28 20 * 29 21 * @var array … … 41 33 42 34 /** 43 * Saved error reporting level 35 * Saved error reporting level. 44 36 * 45 37 * @var int … … 48 40 49 41 /** 50 * List of ajax actions called via POST42 * List of Ajax actions called via POST. 51 43 * 52 44 * @var array … … 140 132 141 133 /** 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. 144 137 */ 145 138 public function setUp() { … … 163 156 164 157 /** 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. 167 161 */ 168 162 public function tearDown() { … … 179 173 180 174 /** 181 * Clear login cookies, unset the current user175 * Clears login cookies, unsets the current user. 182 176 */ 183 177 public function logout() { … … 190 184 191 185 /** 192 * Return our callback handler186 * Returns our callback handler 193 187 * 194 188 * @return callback … … 199 193 200 194 /** 201 * Handler for wp_die() 195 * Handler for wp_die(). 196 * 202 197 * Save the output for analysis, stop execution by throwing an exception. 198 * 203 199 * Error conditions (no output, just die) will throw <code>WPAjaxDieStopException( $message )</code> 204 200 * You can test for this with: … … 212 208 * </code> 213 209 * 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. 215 215 */ 216 216 public function dieHandler( $message ) { … … 229 229 230 230 /** 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. 235 236 */ 236 237 protected function _setRole( $role ) { … … 242 243 243 244 /** 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. 249 251 */ 250 252 protected function _handleAjax( $action ) {
Note: See TracChangeset
for help on using the changeset viewer.