@@ -14,75 +14,97 @@ public function setUp() {
1414 parent ::setUp ();
1515 }
1616
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 ' ;
2023 $ response = wp_remote_head ( $ url );
2124
2225 $ this ->skipTestOnTimeout ( $ response );
2326
2427 $ headers = wp_remote_retrieve_headers ( $ response );
2528
2629 $ this ->assertInternalType ( 'array ' , $ headers , "Reply wasn't array. " );
27- $ this ->assertEquals ( 'image/jpeg ' , $ headers ['content-type ' ] );
28- $ this ->assertEquals ( '40148 ' , $ headers ['content-length ' ] );
29- $ this ->assertEquals ( ' 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 ) );
3033 }
3134
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 ' ;
3541 $ response = wp_remote_head ( $ url );
3642
3743 $ this ->skipTestOnTimeout ( $ response );
3844 $ this ->assertEquals ( '301 ' , wp_remote_retrieve_response_code ( $ response ) );
3945 }
4046
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 ' ;
4352 $ response = wp_remote_head ( $ url );
4453
4554 $ this ->skipTestOnTimeout ( $ response );
4655 $ this ->assertInternalType ( 'array ' , $ response , "Reply wasn't array. " );
4756 $ this ->assertEquals ( '404 ' , wp_remote_retrieve_response_code ( $ response ) );
4857 }
4958
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 ' ;
5266
5367 $ response = wp_remote_get ( $ url );
5468
5569 $ this ->skipTestOnTimeout ( $ response );
5670
5771 $ headers = wp_remote_retrieve_headers ( $ response );
5872
59- // should return the same headers as a head request
73+ // Should return the same headers as a HEAD request.
6074 $ this ->assertInternalType ( 'array ' , $ headers , "Reply wasn't array. " );
61- $ this ->assertEquals ( 'image/jpeg ' , $ headers ['content-type ' ] );
62- $ this ->assertEquals ( '40148 ' , $ headers ['content-length ' ] );
63- $ this ->assertEquals ( ' 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 ) );
6478 }
6579
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 ' ;
6988
7089 $ response = wp_remote_get ( $ url );
7190
7291 $ this ->skipTestOnTimeout ( $ response );
7392
7493 $ headers = wp_remote_retrieve_headers ( $ response );
7594
76- // should return the same headers as a head request
95+ // Should return the same headers as a HEAD request.
7796 $ this ->assertInternalType ( 'array ' , $ headers , "Reply wasn't array. " );
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 ) );
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 ) );
81100 }
82101
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 ' ;
86108
87109 // pretend we've already redirected 5 times
88110 $ response = wp_remote_get ( $ url , array ( 'redirection ' => -1 ) );
0 commit comments