Changeset 50108 for branches/3.7/tests/phpunit/includes/testcase.php
- Timestamp:
- 01/30/2021 09:29:39 PM (4 years ago)
- Location:
- branches/3.7
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.7
- Property svn:mergeinfo changed
/trunk merged: 38757,43511-43512,46682,46996
- Property svn:mergeinfo changed
-
branches/3.7/tests/phpunit/includes/testcase.php
r47492 r50108 55 55 } 56 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 case61 * a test forgets to unregister a post type on its own, or fails before62 * 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 case75 * a test forgets to unregister a taxonomy on its own, or fails before76 * 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();83 }84 85 57 function tearDown() { 86 58 global $wpdb; … … 124 96 $this->markTestSkipped( 'For automated test runs, this test is only run on trunk/master' ); 125 97 } 98 } 99 100 /** 101 * Allow tests to be skipped if the HTTP request times out. 102 * 103 * @param array|WP_Error $response HTTP response. 104 */ 105 public function skipTestOnTimeout( $response ) { 106 if ( ! is_wp_error( $response ) ) { 107 return; 108 } 109 if ( 'connect() timed out!' === $response->get_error_message() ) { 110 $this->markTestSkipped( 'HTTP timeout' ); 111 } 112 113 if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) { 114 $this->markTestSkipped( 'HTTP timeout' ); 115 } 116 117 if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) { 118 $this->markTestSkipped( 'HTTP timeout' ); 119 } 120 121 } 122 123 /** 124 * Unregister existing post types and register defaults. 125 * 126 * Run before each test in order to clean up the global scope, in case 127 * a test forgets to unregister a post type on its own, or fails before 128 * it has a chance to do so. 129 */ 130 protected function reset_post_types() { 131 foreach ( get_post_types() as $pt ) { 132 _unregister_post_type( $pt ); 133 } 134 create_initial_post_types(); 135 } 136 137 /** 138 * Unregister existing taxonomies and register defaults. 139 * 140 * Run before each test in order to clean up the global scope, in case 141 * a test forgets to unregister a taxonomy on its own, or fails before 142 * it has a chance to do so. 143 */ 144 protected function reset_taxonomies() { 145 foreach ( get_taxonomies() as $tax ) { 146 _unregister_taxonomy( $tax ); 147 } 148 create_initial_taxonomies(); 126 149 } 127 150
Note: See TracChangeset
for help on using the changeset viewer.