diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php index 8a6ce3b3b001a..2e73b0de94431 100644 --- a/tests/phpunit/tests/http/base.php +++ b/tests/phpunit/tests/http/base.php @@ -219,6 +219,7 @@ public function test_no_redirection_on_PUT() { ); $this->skipTestOnTimeout( $res ); + $this->assertNotWPError( $res ); $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) ); $this->assertNotEmpty( $res['headers']['location'] ); } @@ -356,6 +357,7 @@ public function test_post_redirect_to_method_300( $response_code, $method ) { $res = wp_remote_post( add_query_arg( 'response_code', $response_code, $url ), array( 'timeout' => 30 ) ); $this->skipTestOnTimeout( $res ); + $this->assertNotWPError( $res ); $this->assertSame( $method, wp_remote_retrieve_body( $res ) ); } @@ -406,6 +408,7 @@ public function test_ip_url_with_host_header() { $res = wp_remote_get( $url, $args ); $this->skipTestOnTimeout( $res ); + $this->assertNotWPError( $res ); $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) ); } @@ -447,6 +450,7 @@ public function test_cookie_handling() { $res = wp_remote_get( $url ); $this->skipTestOnTimeout( $res ); + $this->assertNotWPError( $res ); $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) ); } diff --git a/tests/phpunit/tests/http/functions.php b/tests/phpunit/tests/http/functions.php index 1da190997db06..9c3e54a8b8911 100644 --- a/tests/phpunit/tests/http/functions.php +++ b/tests/phpunit/tests/http/functions.php @@ -15,14 +15,14 @@ public function test_head_request() { $response = wp_remote_head( $url ); $this->skipTestOnTimeout( $response ); + $this->assertNotWPError( $response ); $headers = wp_remote_retrieve_headers( $response ); $this->assertIsArray( $response ); - + $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); $this->assertSame( 'image/png', $headers['Content-Type'] ); $this->assertSame( '153204', $headers['Content-Length'] ); - $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); } /** @@ -34,6 +34,7 @@ public function test_head_redirect() { $response = wp_remote_head( $url ); $this->skipTestOnTimeout( $response ); + $this->assertNotWPError( $response ); $this->assertSame( 301, wp_remote_retrieve_response_code( $response ) ); } @@ -45,6 +46,7 @@ public function test_head_404() { $response = wp_remote_head( $url ); $this->skipTestOnTimeout( $response ); + $this->assertNotWPError( $response ); $this->assertSame( 404, wp_remote_retrieve_response_code( $response ) ); } @@ -59,15 +61,14 @@ public function test_get_request() { $response = wp_remote_get( $url ); $this->skipTestOnTimeout( $response ); + $this->assertNotWPError( $response ); $headers = wp_remote_retrieve_headers( $response ); - $this->assertIsArray( $response ); - // Should return the same headers as a HEAD request. + $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); $this->assertSame( 'image/png', $headers['Content-Type'] ); $this->assertSame( '153204', $headers['Content-Length'] ); - $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); } /** @@ -82,13 +83,14 @@ public function test_get_redirect() { $response = wp_remote_get( $url ); $this->skipTestOnTimeout( $response ); + $this->assertNotWPError( $response ); $headers = wp_remote_retrieve_headers( $response ); // Should return the same headers as a HEAD request. + $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); $this->assertSame( 'image/png', $headers['Content-Type'] ); $this->assertSame( '153204', $headers['Content-Length'] ); - $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); } /** @@ -119,6 +121,7 @@ public function test_get_response_cookies() { $response = wp_remote_head( $url ); $this->skipTestOnTimeout( $response ); + $this->assertNotWPError( $response ); $cookies = wp_remote_retrieve_cookies( $response ); @@ -164,6 +167,7 @@ public function test_get_response_cookies_with_wp_http_cookie_object() { ); $this->skipTestOnTimeout( $response ); + $this->assertNotWPError( $response ); $cookies = wp_remote_retrieve_cookies( $response ); @@ -195,6 +199,7 @@ public function test_get_response_cookies_with_name_value_array() { ); $this->skipTestOnTimeout( $response ); + $this->assertNotWPError( $response ); $cookies = wp_remote_retrieve_cookies( $response ); diff --git a/tests/phpunit/tests/readme.php b/tests/phpunit/tests/readme.php index 7ec762b665345..04faecbb368bf 100644 --- a/tests/phpunit/tests/readme.php +++ b/tests/phpunit/tests/readme.php @@ -94,6 +94,7 @@ public function get_response_body( $url ) { $response = wp_remote_get( $url ); $this->skipTestOnTimeout( $response ); + $this->assertNotWPError( $response ); $response_code = wp_remote_retrieve_response_code( $response ); $response_body = wp_remote_retrieve_body( $response );