Changeset 42343 for trunk/tests/phpunit/includes/testcase-ajax.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/includes/testcase-ajax.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/testcase-ajax.php
r41970 r42343 19 19 /** 20 20 * Last AJAX response. This is set via echo -or- wp_die. 21 * 21 22 * @var string 22 23 */ … … 25 26 /** 26 27 * List of ajax actions called via GET 28 * 27 29 * @var array 28 30 */ 29 31 protected static $_core_actions_get = array( 30 'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache', 31 'autocomplete-user', 'dashboard-widgets', 'logged-in', 32 'fetch-list', 33 'ajax-tag-search', 34 'wp-compression-test', 35 'imgedit-preview', 36 'oembed-cache', 37 'autocomplete-user', 38 'dashboard-widgets', 39 'logged-in', 32 40 ); 33 41 34 42 /** 35 43 * Saved error reporting level 44 * 36 45 * @var int 37 46 */ … … 40 49 /** 41 50 * List of ajax actions called via POST 51 * 42 52 * @var array 43 53 */ 44 54 protected static $_core_actions_post = array( 45 'oembed_cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link', 46 'delete-meta', 'delete-post', 'trash-post', 'untrash-post', 'delete-page', 'dim-comment', 47 'add-link-category', 'add-tag', 'get-tagcloud', 'get-comments', 'replyto-comment', 48 'edit-comment', 'add-menu-item', 'add-meta', 'add-user', 'closed-postboxes', 49 'hidden-columns', 'update-welcome-panel', 'menu-get-metabox', 'wp-link-ajax', 50 'menu-locations-save', 'menu-quick-search', 'meta-box-order', 'get-permalink', 51 'sample-permalink', 'inline-save', 'inline-save-tax', 'find_posts', 'widgets-order', 52 'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post', 53 'wp-remove-post-lock', 'dismiss-wp-pointer', 'send-attachment-to-editor', 'heartbeat', 'nopriv_heartbeat', 'get-revision-diffs', 54 'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail', 55 'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'press-this-save-post', 56 'press-this-add-category', 'crop-image', 'generate-password', 'save-wporg-username', 'delete-plugin', 57 'search-plugins', 'search-install-plugins', 'activate-plugin', 'update-theme', 'delete-theme', 58 'install-theme', 'get-post-thumbnail-html', 55 'oembed_cache', 56 'image-editor', 57 'delete-comment', 58 'delete-tag', 59 'delete-link', 60 'delete-meta', 61 'delete-post', 62 'trash-post', 63 'untrash-post', 64 'delete-page', 65 'dim-comment', 66 'add-link-category', 67 'add-tag', 68 'get-tagcloud', 69 'get-comments', 70 'replyto-comment', 71 'edit-comment', 72 'add-menu-item', 73 'add-meta', 74 'add-user', 75 'closed-postboxes', 76 'hidden-columns', 77 'update-welcome-panel', 78 'menu-get-metabox', 79 'wp-link-ajax', 80 'menu-locations-save', 81 'menu-quick-search', 82 'meta-box-order', 83 'get-permalink', 84 'sample-permalink', 85 'inline-save', 86 'inline-save-tax', 87 'find_posts', 88 'widgets-order', 89 'save-widget', 90 'set-post-thumbnail', 91 'date_format', 92 'time_format', 93 'wp-fullscreen-save-post', 94 'wp-remove-post-lock', 95 'dismiss-wp-pointer', 96 'send-attachment-to-editor', 97 'heartbeat', 98 'nopriv_heartbeat', 99 'get-revision-diffs', 100 'save-user-color-scheme', 101 'update-widget', 102 'query-themes', 103 'parse-embed', 104 'set-attachment-thumbnail', 105 'parse-media-shortcode', 106 'destroy-sessions', 107 'install-plugin', 108 'update-plugin', 109 'press-this-save-post', 110 'press-this-add-category', 111 'crop-image', 112 'generate-password', 113 'save-wporg-username', 114 'delete-plugin', 115 'search-plugins', 116 'search-install-plugins', 117 'activate-plugin', 118 'update-theme', 119 'delete-theme', 120 'install-theme', 121 'get-post-thumbnail-html', 59 122 ); 60 123 … … 104 167 parent::tearDown(); 105 168 $_POST = array(); 106 $_GET = array();169 $_GET = array(); 107 170 unset( $GLOBALS['post'] ); 108 171 unset( $GLOBALS['comment'] ); … … 118 181 public function logout() { 119 182 unset( $GLOBALS['current_user'] ); 120 $cookies = array(AUTH_COOKIE, SECURE_AUTH_COOKIE, LOGGED_IN_COOKIE, USER_COOKIE, PASS_COOKIE); 121 foreach ( $cookies as $c ) 122 unset( $_COOKIE[$c] ); 183 $cookies = array( AUTH_COOKIE, SECURE_AUTH_COOKIE, LOGGED_IN_COOKIE, USER_COOKIE, PASS_COOKIE ); 184 foreach ( $cookies as $c ) { 185 unset( $_COOKIE[ $c ] ); 186 } 123 187 } 124 188 125 189 /** 126 190 * Return our callback handler 191 * 127 192 * @return callback 128 193 */ … … 144 209 * $this->setExpectedException( 'WPAjaxDieContinueException', 'something contained in $message' ); 145 210 * </code> 211 * 146 212 * @param string $message 147 213 */ … … 163 229 * Switch between user roles 164 230 * E.g. administrator, editor, author, contributor, subscriber 231 * 165 232 * @param string $role 166 233 */ 167 234 protected function _setRole( $role ) { 168 $post = $_POST;235 $post = $_POST; 169 236 $user_id = self::factory()->user->create( array( 'role' => $role ) ); 170 237 wp_set_current_user( $user_id ); 171 $_POST = array_merge( $_POST, $post);238 $_POST = array_merge( $_POST, $post ); 172 239 } 173 240 … … 176 243 * Capture the output via output buffering, and if there is any, store 177 244 * it in $this->_last_response. 245 * 178 246 * @param string $action 179 247 */ … … 195 263 // Save the output 196 264 $buffer = ob_get_clean(); 197 if ( ! empty( $buffer ) )265 if ( ! empty( $buffer ) ) { 198 266 $this->_last_response = $buffer; 267 } 199 268 } 200 269 }
Note: See TracChangeset
for help on using the changeset viewer.