Changeset 57999 for branches/5.2
- Timestamp:
- 04/15/2024 01:29:17 PM (6 months ago)
- Location:
- branches/5.2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.2
-
branches/5.2/tests/phpunit/tests/http/functions.php
r50093 r57999 15 15 } 16 16 17 function test_head_request() { 18 // this url give a direct 200 response 19 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; 17 /** 18 * @covers ::wp_remote_head 19 */ 20 public function test_head_request() { 21 // This URL gives a direct 200 response. 22 $url = 'https://s.w.org/screenshots/3.9/dashboard.png'; 20 23 $response = wp_remote_head( $url ); 21 24 … … 26 29 $this->assertInternalType( 'array', $response ); 27 30 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 ) );31 $this->assertSame( 'image/png', $headers['Content-Type'] ); 32 $this->assertSame( '153204', $headers['Content-Length'] ); 33 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 31 34 } 32 35 33 36 function test_head_redirect() { 34 37 // this url will 301 redirect 35 $url = 'https:// asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg';38 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 36 39 $response = wp_remote_head( $url ); 37 40 … … 40 43 } 41 44 42 function test_head_404() { 43 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg'; 45 /** 46 * @covers ::wp_remote_head 47 */ 48 public function test_head_404() { 49 $url = 'https://wordpress.org/screenshots/3.9/awefasdfawef.jpg'; 44 50 $response = wp_remote_head( $url ); 45 51 … … 48 54 } 49 55 50 function test_get_request() { 51 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; 56 /** 57 * @covers ::wp_remote_get 58 * @covers ::wp_remote_retrieve_headers 59 * @covers ::wp_remote_retrieve_response_code 60 */ 61 public function test_get_request() { 62 $url = 'https://s.w.org/screenshots/3.9/dashboard.png'; 52 63 53 64 $response = wp_remote_get( $url ); … … 59 70 $this->assertInternalType( 'array', $response ); 60 71 61 // should return the same headers as a head request 62 $this->assertEquals( 'image/jpeg', $headers['content-type'] ); 63 $this->assertEquals( '40148', $headers['content-length'] ); 64 $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) ); 65 } 66 67 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'; 72 // Should return the same headers as a HEAD request. 73 $this->assertSame( 'image/png', $headers['Content-Type'] ); 74 $this->assertSame( '153204', $headers['Content-Length'] ); 75 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 76 } 77 78 /** 79 * @covers ::wp_remote_get 80 * @covers ::wp_remote_retrieve_headers 81 * @covers ::wp_remote_retrieve_response_code 82 */ 83 public function test_get_redirect() { 84 // This will redirect to wordpress.org. 85 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 70 86 71 87 $response = wp_remote_get( $url ); … … 75 91 $headers = wp_remote_retrieve_headers( $response ); 76 92 77 // should return the same headers as a head request 78 $this->assertEquals( 'image/jpeg', $headers['content-type'] ); 79 $this->assertEquals( '40148', $headers['content-length'] ); 80 $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) ); 81 } 82 83 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'; 93 // Should return the same headers as a HEAD request. 94 $this->assertSame( 'image/png', $headers['Content-Type'] ); 95 $this->assertSame( '153204', $headers['Content-Length'] ); 96 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 97 } 98 99 /** 100 * @covers ::wp_remote_get 101 */ 102 public function test_get_redirect_limit_exceeded() { 103 // This will redirect to wordpress.org. 104 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 86 105 87 106 // pretend we've already redirected 5 times -
branches/5.2/tests/phpunit/tests/image/functions.php
r48484 r57999 336 336 337 337 $file = wp_crop_image( 338 'https:// asdftestblog1.files.wordpress.com/2008/04/canola.jpg',338 'https://s.w.org/screenshots/3.9/dashboard.png', 339 339 0, 340 340 0, … … 344 344 100, 345 345 false, 346 DIR_TESTDATA . '/images/' . __FUNCTION__ . '. jpg'346 DIR_TESTDATA . '/images/' . __FUNCTION__ . '.png' 347 347 ); 348 348 $this->assertNotWPError( $file ); … … 375 375 376 376 $file = wp_crop_image( 377 'https:// asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg',377 'https://wordpress.org/screenshots/3.9/canoladoesnotexist.jpg', 378 378 0, 379 379 0,
Note: See TracChangeset
for help on using the changeset viewer.