Changeset 58014
- Timestamp:
- 04/16/2024 11:25:11 PM (8 months ago)
- Location:
- branches/4.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.3
-
branches/4.3/tests/phpunit/tests/http/functions.php
r50101 r58014 14 14 } 15 15 16 function test_head_request() { 17 // this url give a direct 200 response 18 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; 16 /** 17 * @covers ::wp_remote_head 18 */ 19 public function test_head_request() { 20 // This URL gives a direct 200 response. 21 $url = 'https://s.w.org/screenshots/3.9/dashboard.png'; 19 22 $response = wp_remote_head( $url ); 20 23 … … 24 27 25 28 $this->assertInternalType( 'array', $headers, "Reply wasn't array." ); 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 31 function test_head_redirect() { 32 // this url will 301 redirect 33 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; 34 /** 35 * @covers ::wp_remote_head 36 */ 37 public function test_head_redirect() { 38 // This URL will 301 redirect. 39 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 34 40 $response = wp_remote_head( $url ); 35 41 … … 38 44 } 39 45 40 function test_head_404() { 41 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg'; 46 /** 47 * @covers ::wp_remote_head 48 */ 49 public function test_head_404() { 50 $url = 'https://wordpress.org/screenshots/3.9/awefasdfawef.jpg'; 42 51 $response = wp_remote_head( $url ); 43 52 … … 47 56 } 48 57 49 function test_get_request() { 50 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; 58 /** 59 * @covers ::wp_remote_get 60 * @covers ::wp_remote_retrieve_headers 61 * @covers ::wp_remote_retrieve_response_code 62 */ 63 public function test_get_request() { 64 $url = 'https://s.w.org/screenshots/3.9/dashboard.png'; 51 65 52 66 $response = wp_remote_get( $url ); … … 56 70 $headers = wp_remote_retrieve_headers( $response ); 57 71 58 // should return the same headers as a head request72 // Should return the same headers as a HEAD request. 59 73 $this->assertInternalType( 'array', $headers, "Reply wasn't array." ); 60 $this->assert Equals( 'image/jpeg', $headers['content-type'] );61 $this->assert Equals( '40148', $headers['content-length'] );62 $this->assert Equals( '200', wp_remote_retrieve_response_code( $response ) );74 $this->assertSame( 'image/png', $headers['content-type'] ); 75 $this->assertSame( '153204', $headers['content-length'] ); 76 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 63 77 } 64 78 65 function test_get_redirect() { 66 // this will redirect to asdftestblog1.files.wordpress.com 67 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; 79 /** 80 * @covers ::wp_remote_get 81 * @covers ::wp_remote_retrieve_headers 82 * @covers ::wp_remote_retrieve_response_code 83 */ 84 public function test_get_redirect() { 85 // This will redirect to wordpress.org. 86 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 68 87 69 88 $response = wp_remote_get( $url ); … … 73 92 $headers = wp_remote_retrieve_headers( $response ); 74 93 75 // should return the same headers as a head request94 // Should return the same headers as a HEAD request. 76 95 $this->assertInternalType( 'array', $headers, "Reply wasn't array." ); 77 $this->assert Equals( 'image/jpeg', $headers['content-type'] );78 $this->assert Equals( '40148', $headers['content-length'] );79 $this->assert Equals( '200', wp_remote_retrieve_response_code( $response ) );96 $this->assertSame( 'image/png', $headers['content-type'] ); 97 $this->assertSame( '153204', $headers['content-length'] ); 98 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 80 99 } 81 100 82 function test_get_redirect_limit_exceeded() { 83 // this will redirect to asdftestblog1.files.wordpress.com 84 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; 101 /** 102 * @covers ::wp_remote_get 103 */ 104 public function test_get_redirect_limit_exceeded() { 105 // This will redirect to wordpress.org. 106 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 85 107 86 108 // pretend we've already redirected 5 times -
branches/4.3/tests/phpunit/tests/image/functions.php
r31512 r58014 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.