Changeset 29251
- Timestamp:
- 07/19/2014 11:58:07 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/testcase.php
r29120 r29251 12 12 protected $caught_doing_it_wrong = array(); 13 13 14 protected static $hooks_saved = array(); 14 15 protected static $ignore_files; 15 16 … … 24 25 if ( ! self::$ignore_files ) { 25 26 self::$ignore_files = $this->scan_user_uploads(); 27 } 28 29 if ( ! self::$hooks_saved ) { 30 $this->_backup_hooks(); 26 31 } 27 32 … … 53 58 remove_filter( 'query', array( $this, '_drop_temporary_tables' ) ); 54 59 remove_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) ); 60 $this->_restore_hooks(); 55 61 } 56 62 … … 61 67 } 62 68 69 /** 70 * Saves the action and filter-related globals so they can be restored later 71 * 72 * Stores $merged_filters, $wp_actions, $wp_current_filter, and $wp_filter 73 * on a class variable so they can be restored on tearDown() using _restore_hooks() 74 * @global array $merged_filters 75 * @global array $wp_actions 76 * @global array $wp_current_filter 77 * @global array $wp_filter 78 * @return void 79 */ 80 protected function _backup_hooks() { 81 $globals = array( 'merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter' ); 82 foreach ( $globals as $key ) { 83 self::$hooks_saved[ $key ] = $GLOBALS[ $key ]; 84 } 85 } 86 87 /** 88 * Restores the hook-related globals to their state at setUp() 89 * 90 * so that future tests aren't affected by hooks set during this last test 91 * 92 * @global array $merged_filters 93 * @global array $wp_actions 94 * @global array $wp_current_filter 95 * @global array $wp_filter 96 * @return void 97 */ 98 protected function _restore_hooks(){ 99 $globals = array( 'merged_filters', 'wp_actions', 'wp_current_filter', 'wp_filter' ); 100 foreach ( $globals as $key ) { 101 $GLOBALS[ $key ] = self::$hooks_saved[ $key ]; 102 } 103 } 104 63 105 function flush_cache() { 64 106 global $wp_object_cache;
Note: See TracChangeset
for help on using the changeset viewer.