Changeset 57997 for branches/5.4/tests/phpunit/tests/http/functions.php
- Timestamp:
- 04/15/2024 12:30:10 PM (8 months ago)
- Location:
- branches/5.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.4
-
branches/5.4/tests/phpunit/tests/http/functions.php
r47122 r57997 17 17 function test_head_request() { 18 18 // This URL gives a direct 200 response. 19 $url = 'https:// asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';19 $url = 'https://s.w.org/screenshots/3.9/dashboard.png'; 20 20 $response = wp_remote_head( $url ); 21 21 … … 26 26 $this->assertInternalType( 'array', $response ); 27 27 28 $this->assert Equals( 'image/jpeg', $headers['content-type'] );29 $this->assert Equals( '40148', $headers['content-length'] );30 $this->assert Equals( '200', wp_remote_retrieve_response_code( $response ) );28 $this->assertSame( 'image/png', $headers['Content-Type'] ); 29 $this->assertSame( '153204', $headers['Content-Length'] ); 30 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 31 31 } 32 32 33 33 function test_head_redirect() { 34 34 // This URL will 301 redirect. 35 $url = 'https:// asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';35 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 36 36 $response = wp_remote_head( $url ); 37 37 … … 40 40 } 41 41 42 function test_head_404() { 43 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg'; 42 /** 43 * @covers ::wp_remote_head 44 */ 45 public function test_head_404() { 46 $url = 'https://wordpress.org/screenshots/3.9/awefasdfawef.jpg'; 44 47 $response = wp_remote_head( $url ); 45 48 … … 48 51 } 49 52 50 function test_get_request() { 51 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; 53 /** 54 * @covers ::wp_remote_get 55 * @covers ::wp_remote_retrieve_headers 56 * @covers ::wp_remote_retrieve_response_code 57 */ 58 public function test_get_request() { 59 $url = 'https://s.w.org/screenshots/3.9/dashboard.png'; 52 60 53 61 $response = wp_remote_get( $url ); … … 60 68 61 69 // Should return the same headers as a HEAD request. 62 $this->assert Equals( 'image/jpeg', $headers['content-type'] );63 $this->assert Equals( '40148', $headers['content-length'] );64 $this->assert Equals( '200', wp_remote_retrieve_response_code( $response ) );70 $this->assertSame( 'image/png', $headers['Content-Type'] ); 71 $this->assertSame( '153204', $headers['Content-Length'] ); 72 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 65 73 } 66 74 67 75 function test_get_redirect() { 68 // This will redirect to asdftestblog1.files.wordpress.com.69 $url = 'https:// asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';76 // This will redirect to wordpress.org. 77 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 70 78 71 79 $response = wp_remote_get( $url ); … … 76 84 77 85 // Should return the same headers as a HEAD request. 78 $this->assert Equals( 'image/jpeg', $headers['content-type'] );79 $this->assert Equals( '40148', $headers['content-length'] );80 $this->assert Equals( '200', wp_remote_retrieve_response_code( $response ) );86 $this->assertSame( 'image/png', $headers['Content-Type'] ); 87 $this->assertSame( '153204', $headers['Content-Length'] ); 88 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 81 89 } 82 90 83 91 function test_get_redirect_limit_exceeded() { 84 // This will redirect to asdftestblog1.files.wordpress.com.85 $url = 'https:// asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';92 // This will redirect to wordpress.org. 93 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 86 94 87 95 // Pretend we've already redirected 5 times.
Note: See TracChangeset
for help on using the changeset viewer.