Make WordPress Core

Ticket #43231: 43231.tests.patch

File 43231.tests.patch, 1.1 KB (added by soulseekah, 7 years ago)

Initial tests

  • tests/phpunit/tests/http/functions.php

    diff --git tests/phpunit/tests/http/functions.php tests/phpunit/tests/http/functions.php
    index e3d15cb..37457f2 100644
    class Tests_HTTP_Functions extends WP_UnitTestCase { 
    152152                $this->assertSame( 'test', $cookie->name );
    153153                $this->assertSame( 'foo', $cookie->value );
    154154        }
     155
     156        /**
     157         * @ticket 43231
     158         */
     159        function test_get_cookie_host_only() {
     160                $url = 'https://login.wordpress.org/wp-login.php';
     161
     162                $response = wp_remote_get( $url );
     163                $requests_response = $response['http_response']->get_response_object();
     164
     165                // login.wordpress.org issues a .wordpress.org cookie, host-only flag is set to false
     166                $this->assertEquals( $requests_response->cookies['wordpress_test_cookie']->flags['host-only'], false );
     167
     168                // Regurgitate (Requests_Cookie -> WP_Http_Cookie -> Requests_Cookie)
     169                $cookies = WP_Http::normalize_cookies( wp_remote_retrieve_cookies( $response ) );
     170
     171                $this->assertEquals( $cookies['wordpress_test_cookie']->flags['host-only'], false, 'host-only flag data lost' );
     172        }
    155173}