Changeset 42343 for trunk/tests/phpunit/includes/functions.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/functions.php
r41966 r42343 21 21 22 22 // For adding hooks before loading WP 23 function tests_add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1) {23 function tests_add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) { 24 24 global $wp_filter; 25 25 … … 27 27 add_filter( $tag, $function_to_add, $priority, $accepted_args ); 28 28 } else { 29 $idx = _test_filter_build_unique_id($tag, $function_to_add, $priority); 30 $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); 29 $idx = _test_filter_build_unique_id( $tag, $function_to_add, $priority ); 30 $wp_filter[ $tag ][ $priority ][ $idx ] = array( 31 'function' => $function_to_add, 32 'accepted_args' => $accepted_args, 33 ); 31 34 } 32 35 return true; 33 36 } 34 37 35 function _test_filter_build_unique_id( $tag, $function, $priority) {36 if ( is_string( $function) )38 function _test_filter_build_unique_id( $tag, $function, $priority ) { 39 if ( is_string( $function ) ) { 37 40 return $function; 41 } 38 42 39 if ( is_object( $function) ) {43 if ( is_object( $function ) ) { 40 44 // Closures are currently implemented as objects 41 45 $function = array( $function, '' ); … … 44 48 } 45 49 46 if ( is_object($function[0]) ) {47 return spl_object_hash( $function[0]) . $function[1];48 } else if ( is_string($function[0]) ) {50 if ( is_object( $function[0] ) ) { 51 return spl_object_hash( $function[0] ) . $function[1]; 52 } elseif ( is_string( $function[0] ) ) { 49 53 // Static Calling 50 return $function[0] .$function[1];54 return $function[0] . $function[1]; 51 55 } 52 56 } … … 61 65 $wpdb->commentmeta, 62 66 $wpdb->term_relationships, 63 $wpdb->termmeta 67 $wpdb->termmeta, 64 68 ) as $table ) { 65 69 $wpdb->query( "DELETE FROM {$table}" ); … … 68 72 foreach ( array( 69 73 $wpdb->terms, 70 $wpdb->term_taxonomy 74 $wpdb->term_taxonomy, 71 75 ) as $table ) { 72 76 $wpdb->query( "DELETE FROM {$table} WHERE term_id != 1" ); … … 97 101 98 102 function _wp_die_handler( $message, $title = '', $args = array() ) { 99 if ( ! $GLOBALS['_wp_die_disabled'] ) {100 _wp_die_handler_txt( $message, $title, $args );103 if ( ! $GLOBALS['_wp_die_disabled'] ) { 104 _wp_die_handler_txt( $message, $title, $args ); 101 105 } else { 102 106 //Ignore at our peril … … 126 130 if ( ! empty( $args ) ) { 127 131 echo "Args: \n"; 128 foreach ( $args as $k => $v ){132 foreach ( $args as $k => $v ) { 129 133 echo "\t $k : $v\n"; 130 134 } … … 138 142 if ( ! empty( $args ) ) { 139 143 echo "Args: \n"; 140 foreach ( $args as $k => $v ){144 foreach ( $args as $k => $v ) { 141 145 echo "\t $k : $v\n"; 142 146 } … … 164 168 165 169 $uploads['subdir'] = ''; 166 $uploads['path'] = str_replace( $subdir, '', $uploads['path'] );167 $uploads['url'] = str_replace( $subdir, '', $uploads['url'] );170 $uploads['path'] = str_replace( $subdir, '', $uploads['path'] ); 171 $uploads['url'] = str_replace( $subdir, '', $uploads['url'] ); 168 172 169 173 return $uploads; … … 174 178 */ 175 179 function _upload_dir_https( $uploads ) { 176 $uploads['url'] = str_replace( 'http://', 'https://', $uploads['url'] );180 $uploads['url'] = str_replace( 'http://', 'https://', $uploads['url'] ); 177 181 $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] ); 178 182
Note: See TracChangeset
for help on using the changeset viewer.