Changeset 45013 for branches/4.0/tests/phpunit/includes/testcase.php
- Timestamp:
- 03/26/2019 12:45:57 AM (6 years ago)
- Location:
- branches/4.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.0
- Property svn:mergeinfo changed
/trunk merged: 29860,29869,29954,30160,30530
- Property svn:mergeinfo changed
-
branches/4.0/tests/phpunit/includes/testcase.php
r42065 r45013 38 38 $this->factory = new WP_UnitTest_Factory; 39 39 $this->clean_up_global_scope(); 40 41 /* 42 * When running core tests, ensure that post types and taxonomies 43 * are reset for each test. We skip this step for non-core tests, 44 * given the large number of plugins that register post types and 45 * taxonomies at 'init'. 46 */ 47 if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) { 48 $this->reset_post_types(); 49 $this->reset_taxonomies(); 50 } 51 40 52 $this->start_transaction(); 41 53 $this->expectDeprecated(); 42 54 add_filter( 'wp_die_handler', array( $this, 'get_wp_die_handler' ) ); 55 } 56 57 /** 58 * Unregister existing post types and register defaults. 59 * 60 * Run before each test in order to clean up the global scope, in case 61 * a test forgets to unregister a post type on its own, or fails before 62 * it has a chance to do so. 63 */ 64 protected function reset_post_types() { 65 foreach ( get_post_types() as $pt ) { 66 _unregister_post_type( $pt ); 67 } 68 create_initial_post_types(); 69 } 70 71 /** 72 * Unregister existing taxonomies and register defaults. 73 * 74 * Run before each test in order to clean up the global scope, in case 75 * a test forgets to unregister a taxonomy on its own, or fails before 76 * it has a chance to do so. 77 */ 78 protected function reset_taxonomies() { 79 foreach ( get_taxonomies() as $tax ) { 80 _unregister_taxonomy( $tax ); 81 } 82 create_initial_taxonomies(); 43 83 } 44 84
Note: See TracChangeset
for help on using the changeset viewer.