diff --git tests/phpunit/tests/http/functions.php tests/phpunit/tests/http/functions.php
index e3d15cb..90a1c0a 100644
|
|
class Tests_HTTP_Functions extends WP_UnitTestCase { |
152 | 152 | $this->assertSame( 'test', $cookie->name ); |
153 | 153 | $this->assertSame( 'foo', $cookie->value ); |
154 | 154 | } |
| 155 | |
| 156 | /** |
| 157 | * @ticket 43231 |
| 158 | */ |
| 159 | function test_get_cookie_host_only() { |
| 160 | // emulate WP_Http::request() internals |
| 161 | $requests_response = new Requests_Response(); |
| 162 | |
| 163 | $requests_response->cookies['test'] = Requests_Cookie::parse( 'test=foo; domain=.wordpress.org' ); |
| 164 | $requests_response->cookies['test']->flags['host-only'] = false; // https://github.com/rmccue/Requests/issues/306 |
| 165 | |
| 166 | $http_response = new WP_HTTP_Requests_Response( $requests_response ); |
| 167 | $response = $http_response->to_array(); |
| 168 | |
| 169 | // check the host_only flag in the resulting WP_Http_Cookie |
| 170 | $cookie = wp_remote_retrieve_cookie( $response, 'test' ); |
| 171 | $this->assertEquals( $cookie->domain, 'wordpress.org' ); |
| 172 | $this->assertFalse( $cookie->host_only, 'host-only flag not set' ); |
| 173 | |
| 174 | // regurgitate (Requests_Cookie -> WP_Http_Cookie -> Requests_Cookie) |
| 175 | $cookies = WP_Http::normalize_cookies( wp_remote_retrieve_cookies( $response ) ); |
| 176 | $this->assertFalse( $cookies['test']->flags['host-only'], 'host-only flag data lost' ); |
| 177 | } |
155 | 178 | } |