Make WordPress Core

Changeset 1329 in tests


Ignore:
Timestamp:
07/29/2013 02:09:31 AM (11 years ago)
Author:
dd32
Message:

HTTP-External Tests: Add a test for #16890

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/WPHTTP-testcase-redirection-script.php

    r1318 r1329  
    8484}
    8585
     86if ( isset( $_GET['multiple-location-headers'] ) ) {
     87    if ( ! isset( $_GET['redirected'] ) ) {
     88        header( "Location: $url?multiple-location-headers=1&redirected=one", false );
     89        header( "Location: $url?multiple-location-headers=1&redirected=two", false );
     90        exit;
     91    }
     92    if ( 'two' != $_GET['redirected'] )
     93        echo 'FAIL';
     94    else
     95        echo 'PASS';
     96    exit;
     97}
     98
    8699$rt = isset($_GET['rt']) ? $_GET['rt'] : 5;
    87100$r = isset($_GET['r']) ? $_GET['r'] : 0;
  • trunk/tests/http/base.php

    r1317 r1329  
    243243    }
    244244
     245    /**
     246     * Test HTTP Redirects with multiple Location headers specified
     247     *
     248     * @ticket 16890
     249     */
     250    function test_multiple_location_headers() {
     251        $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?multiple-location-headers=1';
     252        $res = wp_remote_head( $url, array( 'timeout' => 30 ) );
     253
     254        $this->assertInternalType( 'array', wp_remote_retrieve_header( $res, 'location' ) );
     255        $this->assertCount( 2, wp_remote_retrieve_header( $res, 'location' ) );
     256
     257        $res = wp_remote_get( $url, array( 'timeout' => 30 ) );
     258        $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) );
     259
     260    }
     261
    245262}
Note: See TracChangeset for help on using the changeset viewer.