Changeset 58002
- Timestamp:
- 04/15/2024 02:09:59 PM (7 months ago)
- Location:
- branches/4.9
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
branches/4.9/tests/phpunit/tests/http/functions.php
r50096 r58002 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 function test_head_redirect() { 34 // this url will 301 redirect 35 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; 36 /** 37 * @covers ::wp_remote_head 38 */ 39 public function test_head_redirect() { 40 // This URL will 301 redirect. 41 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 36 42 $response = wp_remote_head( $url ); 37 43 … … 40 46 } 41 47 42 function test_head_404() { 43 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg'; 48 /** 49 * @covers ::wp_remote_head 50 */ 51 public function test_head_404() { 52 $url = 'https://wordpress.org/screenshots/3.9/awefasdfawef.jpg'; 44 53 $response = wp_remote_head( $url ); 45 54 … … 48 57 } 49 58 50 function test_get_request() { 51 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; 59 /** 60 * @covers ::wp_remote_get 61 * @covers ::wp_remote_retrieve_headers 62 * @covers ::wp_remote_retrieve_response_code 63 */ 64 public function test_get_request() { 65 $url = 'https://s.w.org/screenshots/3.9/dashboard.png'; 52 66 53 67 $response = wp_remote_get( $url ); … … 59 73 $this->assertInternalType( 'array', $response ); 60 74 61 // should return the same headers as a head request62 $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 ) );75 // Should return the same headers as a HEAD request. 76 $this->assertSame( 'image/png', $headers['Content-Type'] ); 77 $this->assertSame( '153204', $headers['Content-Length'] ); 78 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 65 79 } 66 80 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'; 81 /** 82 * @covers ::wp_remote_get 83 * @covers ::wp_remote_retrieve_headers 84 * @covers ::wp_remote_retrieve_response_code 85 */ 86 public function test_get_redirect() { 87 // This will redirect to wordpress.org. 88 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 70 89 71 90 $response = wp_remote_get( $url ); … … 75 94 $headers = wp_remote_retrieve_headers( $response ); 76 95 77 // should return the same headers as a head request78 $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 ) );96 // Should return the same headers as a HEAD request. 97 $this->assertSame( 'image/png', $headers['Content-Type'] ); 98 $this->assertSame( '153204', $headers['Content-Length'] ); 99 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 81 100 } 82 101 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'; 102 /** 103 * @covers ::wp_remote_get 104 */ 105 public function test_get_redirect_limit_exceeded() { 106 // This will redirect to wordpress.org. 107 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 86 108 87 109 // pretend we've already redirected 5 times -
branches/4.9/tests/phpunit/tests/image/functions.php
r49524 r58002 312 312 } 313 313 314 $file = wp_crop_image( 'https:// asdftestblog1.files.wordpress.com/2008/04/canola.jpg',314 $file = wp_crop_image( 'https://s.w.org/screenshots/3.9/dashboard.png', 315 315 0, 0, 100, 100, 100, 100, false, 316 DIR_TESTDATA . '/images/' . __FUNCTION__ . '. jpg' );316 DIR_TESTDATA . '/images/' . __FUNCTION__ . '.png' ); 317 317 $this->assertNotInstanceOf( 'WP_Error', $file ); 318 318 $this->assertFileExists( $file ); … … 336 336 } 337 337 338 $file = wp_crop_image( 'https:// asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg',338 $file = wp_crop_image( 'https://wordpress.org/screenshots/3.9/canoladoesnotexist.jpg', 339 339 0, 0, 100, 100, 100, 100 ); 340 340 $this->assertInstanceOf( 'WP_Error', $file );
Note: See TracChangeset
for help on using the changeset viewer.