Ticket #28535: ticket-28535.diff
File ticket-28535.diff, 2.6 KB (added by , 10 years ago) |
---|
-
src
-
tests/phpunit/includes/testcase.php
Property changes on: src ___________________________________________________________________ Modified: svn:ignore ## -1,2 +1,3 ## +.htaccess .wp-tests-version -.htaccess +wp-config.php
10 10 protected $caught_deprecated = array(); 11 11 protected $expected_doing_it_wrong = array(); 12 12 protected $caught_doing_it_wrong = array(); 13 protected $hooks_saved = array(); 13 14 14 15 /** 15 16 * @var WP_UnitTest_Factory … … 20 21 set_time_limit(0); 21 22 22 23 global $wpdb; 24 $this->_backup_hooks(); 23 25 $wpdb->suppress_errors = false; 24 26 $wpdb->show_errors = true; 25 27 $wpdb->db_connect(); … … 41 43 remove_filter( 'query', array( $this, '_create_temporary_tables' ) ); 42 44 remove_filter( 'query', array( $this, '_drop_temporary_tables' ) ); 43 45 remove_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) ); 46 $this->_restore_hooks(); 44 47 } 45 48 46 49 function clean_up_global_scope() { … … 49 52 $this->flush_cache(); 50 53 } 51 54 55 /** 56 * Saves the action and filter-related globals so they can be restored later 57 * 58 * Stores $merged_filters, $wp_actions, $wp_current_filter, and $wp_filter 59 * on a class variable so they can be restored on tearDown() using _restore_hooks() 60 * @global array $merged_filters 61 * @global array $wp_actions 62 * @global array $wp_current_filter 63 * @global array $wp_filter 64 * @return void 65 */ 66 protected function _backup_hooks(){ 67 global $merged_filters, $wp_actions, $wp_current_filter, $wp_filter; 68 //create a copy of each as an array element of hooks_saved 69 $this->hooks_saved = array( 70 'merged_filters' => $merged_filters, 71 'wp_actions' => $wp_actions, 72 'wp_current_filter' => $wp_current_filter, 73 'wp_filter' => $wp_filter 74 ); 75 } 76 77 /** 78 * Restores the hook-related globals to their state at setUp() 79 * 80 * so that future tests aren't affected by hooks set during this last test 81 * 82 * @global array $merged_filters 83 * @global array $wp_actions 84 * @global array $wp_current_filter 85 * @global array $wp_filter 86 * @return void 87 */ 88 protected function _restore_hooks(){ 89 global $merged_filters, $wp_actions, $wp_current_filter, $wp_filter; 90 extract( $this->hooks_saved, EXTR_OVERWRITE ); 91 } 52 92 function flush_cache() { 53 93 global $wp_object_cache; 54 94 $wp_object_cache->group_ops = array();