| | 1 | <?php |
| | 2 | /** |
| | 3 | * @group external-http |
| | 4 | */ |
| | 5 | class Tests_External_HTTP_Get_Headers extends WP_UnitTestCase { |
| | 6 | |
| | 7 | public function test_wp_get_http_headers_should_get_succeed() { |
| | 8 | |
| | 9 | $url = 'https://wordpress.org/'; |
| | 10 | $http_headers = wp_get_http_headers( $url ); |
| | 11 | |
| | 12 | $this->assertInternalType( 'object', $http_headers ); |
| | 13 | $this->assertArrayHasKey( 'content-type', $http_headers ); |
| | 14 | $this->assertArrayHasKey( 'date', $http_headers ); |
| | 15 | $this->assertEquals( 'text/html; charset=utf-8', $http_headers['content-type'] ); |
| | 16 | } |
| | 17 | |
| | 18 | public function test_wp_get_http_headers_should_fails() { |
| | 19 | |
| | 20 | $url = 'this_is_not_a_valid_url'; |
| | 21 | $http_headers = wp_get_http_headers( $url ); |
| | 22 | |
| | 23 | $this->assertFalse( $http_headers, "This isn't a valid return for a non-valid url and should raise an error" ); |
| | 24 | } |
| | 25 | } |