Changeset 58013 for branches/4.4
- Timestamp:
- 04/16/2024 11:14:50 PM (8 months ago)
- Location:
- branches/4.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.4
-
branches/4.4/tests/phpunit/tests/http/functions.php
r50091 r58013 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 … … 25 28 26 29 $this->assertInternalType( 'array', $headers, "Reply wasn't array." ); 27 $this->assert Equals( 'image/jpeg', $headers['content-type'] );28 $this->assert Equals( '40148', $headers['content-length'] );29 $this->assert Equals( '200', wp_remote_retrieve_response_code( $response ) );30 $this->assertSame( 'image/png', $headers['content-type'] ); 31 $this->assertSame( '153204', $headers['content-length'] ); 32 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 30 33 } 31 34 32 function test_head_redirect() { 33 // this url will 301 redirect 34 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; 35 /** 36 * @covers ::wp_remote_head 37 */ 38 public function test_head_redirect() { 39 // This URL will 301 redirect. 40 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 35 41 $response = wp_remote_head( $url ); 36 42 … … 39 45 } 40 46 41 function test_head_404() { 42 $url = 'https://asdftestblog1.files.wordpress.com/2007/09/awefasdfawef.jpg'; 47 /** 48 * @covers ::wp_remote_head 49 */ 50 public function test_head_404() { 51 $url = 'https://wordpress.org/screenshots/3.9/awefasdfawef.jpg'; 43 52 $response = wp_remote_head( $url ); 44 53 … … 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 ); … … 57 71 $headers = wp_remote_retrieve_headers( $response ); 58 72 59 // should return the same headers as a head request73 // Should return the same headers as a HEAD request. 60 74 $this->assertInternalType( 'array', $headers, "Reply wasn't array." ); 61 $this->assert Equals( 'image/jpeg', $headers['content-type'] );62 $this->assert Equals( '40148', $headers['content-length'] );63 $this->assert Equals( '200', wp_remote_retrieve_response_code( $response ) );75 $this->assertSame( 'image/png', $headers['content-type'] ); 76 $this->assertSame( '153204', $headers['content-length'] ); 77 $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); 64 78 } 65 79 66 function test_get_redirect() { 67 // this will redirect to asdftestblog1.files.wordpress.com 68 $url = 'https://asdftestblog1.wordpress.com/files/2007/09/2007-06-30-dsc_4700-1.jpg'; 80 /** 81 * @covers ::wp_remote_get 82 * @covers ::wp_remote_retrieve_headers 83 * @covers ::wp_remote_retrieve_response_code 84 */ 85 public function test_get_redirect() { 86 // This will redirect to wordpress.org. 87 $url = 'https://wp.org/screenshots/3.9/dashboard.png'; 69 88 70 89 $response = wp_remote_get( $url ); … … 74 93 $headers = wp_remote_retrieve_headers( $response ); 75 94 76 // should return the same headers as a head request95 // Should return the same headers as a HEAD request. 77 96 $this->assertInternalType( 'array', $headers, "Reply wasn't array." ); 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 ) );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.4/tests/phpunit/tests/image/functions.php
r31512 r58013 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.