Changeset 58007
- Timestamp:
- 04/15/2024 05:23:33 PM (8 months ago)
- Location:
- branches/4.6
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.6
- Property svn:mergeinfo changed
/trunk merged: 52040,56015-56016,57931
- Property svn:mergeinfo changed
-
branches/4.6/src
- Property svn:mergeinfo deleted
-
branches/4.6/tests/phpunit/tests/http/functions.php
r50089 r58007 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 … … 24 27 $headers = wp_remote_retrieve_headers( $response ); 25 28 26 $this->assert Equals( 'image/jpeg', $headers['content-type'] );27 $this->assert Equals( '40148', $headers['content-length'] );28 $this->assert Equals( '200', wp_remote_retrieve_response_code( $response ) );29 $this->assertSame( 'image/png', $headers['Content-Type'] ); 30 $this->assertSame( '153204', $headers['Content-Length'] ); 31 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 29 32 } 30 33 … … 33 36 */ 34 37 function test_returns_array() { 35 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg';38 $url = 'https://s.w.org/screenshots/3.9/dashboard.png'; 36 39 $response = wp_remote_head( $url ); 37 40 $this->assertInternalType( 'array', $response ); 38 41 } 39 42 40 function test_head_redirect() { 41 // this url will 301 redirect 42 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; 43 /** 44 * @covers ::wp_remote_head 45 */ 46 public function test_head_redirect() { 47 // This URL will 301 redirect. 48 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 43 49 $response = wp_remote_head( $url ); 44 50 … … 47 53 } 48 54 49 function test_head_404() { 50 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg'; 55 /** 56 * @covers ::wp_remote_head 57 */ 58 public function test_head_404() { 59 $url = 'https://wordpress.org/screenshots/3.9/awefasdfawef.jpg'; 51 60 $response = wp_remote_head( $url ); 52 61 … … 55 64 } 56 65 57 function test_get_request() { 58 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; 66 /** 67 * @covers ::wp_remote_get 68 * @covers ::wp_remote_retrieve_headers 69 * @covers ::wp_remote_retrieve_response_code 70 */ 71 public function test_get_request() { 72 $url = 'https://s.w.org/screenshots/3.9/dashboard.png'; 73 74 $response = wp_remote_get( $url ); 75 76 $this->skipTestOnTimeout( $response ); 77 78 $headers = wp_remote_retrieve_headers( $response ); 79 80 // Should return the same headers as a HEAD request. 81 $this->assertSame( 'image/png', $headers['Content-Type'] ); 82 $this->assertSame( '153204', $headers['Content-Length'] ); 83 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 84 } 85 86 /** 87 * @covers ::wp_remote_get 88 * @covers ::wp_remote_retrieve_headers 89 * @covers ::wp_remote_retrieve_response_code 90 */ 91 public function test_get_redirect() { 92 // This will redirect to wordpress.org. 93 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 59 94 60 95 $response = wp_remote_get( $url ); … … 64 99 $headers = wp_remote_retrieve_headers( $response ); 65 100 66 // should return the same headers as a head request67 $this->assert Equals( 'image/jpeg', $headers['content-type'] );68 $this->assert Equals( '40148', $headers['content-length'] );69 $this->assert Equals( '200', wp_remote_retrieve_response_code( $response ) );101 // Should return the same headers as a HEAD request. 102 $this->assertSame( 'image/png', $headers['Content-Type'] ); 103 $this->assertSame( '153204', $headers['Content-Length'] ); 104 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 70 105 } 71 106 72 function test_get_redirect() { 73 // this will redirect to asdftestblog1.files.wordpress.com 74 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; 75 76 $response = wp_remote_get( $url ); 77 78 $this->skipTestOnTimeout( $response ); 79 80 $headers = wp_remote_retrieve_headers( $response ); 81 82 // should return the same headers as a head request 83 $this->assertEquals( 'image/jpeg', $headers['content-type'] ); 84 $this->assertEquals( '40148', $headers['content-length'] ); 85 $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) ); 86 } 87 88 function test_get_redirect_limit_exceeded() { 89 // this will redirect to asdftestblog1.files.wordpress.com 90 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; 107 /** 108 * @covers ::wp_remote_get 109 */ 110 public function test_get_redirect_limit_exceeded() { 111 // This will redirect to wordpress.org. 112 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 91 113 92 114 // pretend we've already redirected 5 times -
branches/4.6/tests/phpunit/tests/image/functions.php
r31512 r58007 305 305 } 306 306 307 $file = wp_crop_image( 'https:// asdftestblog1.files.wordpress.com/2008/04/canola.jpg',307 $file = wp_crop_image( 'https://s.w.org/screenshots/3.9/dashboard.png', 308 308 0, 0, 100, 100, 100, 100, false, 309 DIR_TESTDATA . '/images/' . rand_str() . '. jpg' );309 DIR_TESTDATA . '/images/' . rand_str() . '.png' ); 310 310 $this->assertNotInstanceOf( 'WP_Error', $file ); 311 311 $this->assertFileExists( $file ); … … 329 329 } 330 330 331 $file = wp_crop_image( 'https:// asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg',331 $file = wp_crop_image( 'https://wordpress.org/screenshots/3.9/canoladoesnotexist.jpg', 332 332 0, 0, 100, 100, 100, 100 ); 333 333 $this->assertInstanceOf( 'WP_Error', $file );
Note: See TracChangeset
for help on using the changeset viewer.