Changeset 47122 for trunk/tests/phpunit/includes/utils.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/utils.php
r46586 r47122 1 1 <?php 2 2 3 // misc help functions and utilities3 // Misc help functions and utilities. 4 4 5 5 function rand_str( $len = 32 ) { … … 19 19 } 20 20 21 // strip leading and trailing whitespace from each line in the string21 // Strip leading and trailing whitespace from each line in the string. 22 22 function strip_ws( $txt ) { 23 23 $lines = explode( "\n", $txt ); … … 32 32 } 33 33 34 // helper class for testing code that involves actions and filters 35 // typical use: 36 // $ma = new MockAction(); 37 // add_action('foo', array(&$ma, 'action')); 34 /* 35 * Helper class for testing code that involves actions and filters. 36 * Typical use: 37 * $ma = new MockAction(); 38 * add_action( 'foo', array( &$ma, 'action' ) ); 39 */ 38 40 class MockAction { 39 41 var $events; … … 130 132 131 133 function filterall( $tag, ...$args ) { 132 // this one doesn't return the result, so it's safe to use with the new 'all' filter134 // This one doesn't return the result, so it's safe to use with the new 'all' filter. 133 135 if ( $this->debug ) { 134 136 dmp( __FUNCTION__, $this->current_filter() ); … … 142 144 } 143 145 144 // return a list of all the actions, tags and args146 // Return a list of all the actions, tags and args. 145 147 function get_events() { 146 148 return $this->events; 147 149 } 148 150 149 // return a count of the number of times the action was called since the last reset151 // Return a count of the number of times the action was called since the last reset. 150 152 function get_call_count( $tag = '' ) { 151 153 if ( $tag ) { … … 161 163 } 162 164 163 // return an array of the tags that triggered calls to this action165 // Return an array of the tags that triggered calls to this action. 164 166 function get_tags() { 165 167 $out = array(); … … 170 172 } 171 173 172 // return an array of args passed in calls to this action174 // Return an array of args passed in calls to this action. 173 175 function get_args() { 174 176 $out = array(); … … 180 182 } 181 183 182 // convert valid xml to an array tree structure183 // kinda lame but it works with a default php 4 installation184 // Convert valid XML to an array tree structure. 185 // Kinda lame, but it works with a default PHP 4 installation. 184 186 class TestXMLParser { 185 187 var $xml; … … 313 315 } 314 316 315 // recursively generate some quick assertEquals tests based on an array317 // Recursively generate some quick assertEquals() tests based on an array. 316 318 function gen_tests_array( $name, $array ) { 317 319 $out = array(); … … 368 370 } 369 371 370 // mask out any input fields matching the given name372 // Mask out any input fields matching the given name. 371 373 function mask_input_value( $in, $name = '_wpnonce' ) { 372 374 return preg_replace( '@<input([^>]*) name="' . preg_quote( $name ) . '"([^>]*) value="[^>]*" />@', '<input$1 name="' . preg_quote( $name ) . '"$2 value="***" />', $in ); … … 396 398 397 399 function _cleanup_query_vars() { 398 // clean out globals to stop them polluting wp and wp_query400 // Clean out globals to stop them polluting wp and wp_query. 399 401 foreach ( $GLOBALS['wp']->public_query_vars as $v ) { 400 402 unset( $GLOBALS[ $v ] );
Note: See TracChangeset
for help on using the changeset viewer.