Changeset 50094
- Timestamp:
- 01/30/2021 01:05:57 PM (4 years ago)
- Location:
- branches/5.1
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.1
- Property svn:mergeinfo changed
/trunk merged: 46682,46996
- Property svn:mergeinfo changed
-
branches/5.1/tests/phpunit/includes/abstract-testcase.php
r44719 r50094 173 173 174 174 /** 175 * Allow tests to be skipped on some automated runs 175 * Allow tests to be skipped on some automated runs. 176 176 * 177 177 * For test runs on Travis for something other than trunk/master … … 213 213 $this->markTestSkipped( 'Test does not run on Multisite' ); 214 214 } 215 } 216 217 /** 218 * Allow tests to be skipped if the HTTP request times out. 219 * 220 * @param array|WP_Error $response HTTP response. 221 */ 222 public function skipTestOnTimeout( $response ) { 223 if ( ! is_wp_error( $response ) ) { 224 return; 225 } 226 if ( 'connect() timed out!' === $response->get_error_message() ) { 227 $this->markTestSkipped( 'HTTP timeout' ); 228 } 229 230 if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) { 231 $this->markTestSkipped( 'HTTP timeout' ); 232 } 233 234 if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) { 235 $this->markTestSkipped( 'HTTP timeout' ); 236 } 237 215 238 } 216 239 -
branches/5.1/tests/phpunit/tests/external-http/basic.php
r40519 r50094 14 14 15 15 $response = wp_remote_get( 'https://secure.php.net/supported-versions.php' ); 16 if ( 200 != wp_remote_retrieve_response_code( $response ) ) { 17 $this->fail( 'Could not contact PHP.net to check versions.' ); 16 17 $this->skipTestOnTimeout( $response ); 18 19 $response_code = wp_remote_retrieve_response_code( $response ); 20 if ( 200 !== $response_code ) { 21 $this->fail( sprintf( 'Could not contact PHP.net to check versions. Response code: %s', $response_code ) ); 18 22 } 23 19 24 $php = wp_remote_retrieve_body( $response ); 20 25 … … 26 31 27 32 $response = wp_remote_get( "https://dev.mysql.com/doc/relnotes/mysql/{$matches[1]}/en/" ); 28 if ( 200 != wp_remote_retrieve_response_code( $response ) ) { 29 $this->fail( 'Could not contact dev.MySQL.com to check versions.' ); 33 34 $this->skipTestOnTimeout( $response ); 35 36 $response_code = wp_remote_retrieve_response_code( $response ); 37 if ( 200 !== $response_code ) { 38 $this->fail( sprintf( 'Could not contact dev.MySQL.com to check versions. Response code: %s', $response_code ) ); 30 39 } 40 31 41 $mysql = wp_remote_retrieve_body( $response ); 32 42 -
branches/5.1/tests/phpunit/tests/http/base.php
r44577 r50094 18 18 protected $http_request_args; 19 19 20 /**21 * Mark test as skipped if the HTTP request times out.22 */23 function skipTestOnTimeout( $response ) {24 if ( ! is_wp_error( $response ) ) {25 return;26 }27 if ( 'connect() timed out!' === $response->get_error_message() ) {28 $this->markTestSkipped( 'HTTP timeout' );29 }30 31 if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {32 $this->markTestSkipped( 'HTTP timeout' );33 }34 35 if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {36 $this->markTestSkipped( 'HTTP timeout' );37 }38 39 }40 41 20 function setUp() { 42 21 parent::setUp(); -
branches/5.1/tests/phpunit/tests/http/functions.php
r43571 r50094 6 6 */ 7 7 class Tests_HTTP_Functions extends WP_UnitTestCase { 8 9 /**10 * Mark test as skipped if the HTTP request times out.11 */12 function skipTestOnTimeout( $response ) {13 if ( ! is_wp_error( $response ) ) {14 return;15 }16 if ( 'connect() timed out!' === $response->get_error_message() ) {17 $this->markTestSkipped( 'HTTP timeout' );18 }19 20 if ( false !== strpos( $response->get_error_message(), 'timed out after' ) ) {21 $this->markTestSkipped( 'HTTP timeout' );22 }23 24 if ( 0 === strpos( $response->get_error_message(), 'stream_socket_client(): unable to connect to tcp://s.w.org:80' ) ) {25 $this->markTestSkipped( 'HTTP timeout' );26 }27 28 }29 8 30 9 public function setUp() {
Note: See TracChangeset
for help on using the changeset viewer.