Make WordPress Core

Changeset 1316 in tests


Ignore:
Timestamp:
07/28/2013 05:28:08 AM (11 years ago)
Author:
dd32
Message:

HTTP-External tests: Add additional tests for #16889 and #17588

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/http/base.php

    r1231 r1316  
    141141
    142142    /**
     143     * Test handling of PUT requests on redirects
     144     *
     145     * @ticket 16889
     146     */
     147    function test_no_redirection_on_PUT() {
     148        $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?201-location=1';
     149
     150        // Test 301 - POST to POST
     151        $res = wp_remote_request( $url, array( 'method' => 'PUT', 'timeout' => 30 ) );
     152        $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) );
     153        $this->assertTrue( !empty( $res['headers']['location'] ) );
     154    }
     155
     156    /**
    143157     * @ticket 11888
    144158     */
     
    155169                continue;
    156170            $parts = explode(':', $value,2);
    157             unset($heaers[$key]);
     171            unset($headers[$key]);
    158172            $headers[ $parts[0] ] = $parts[1];
    159173        }
     
    178192        unlink($res['filename']); // Remove the temporary file
    179193    }
     194
     195    /**
     196     * Test POST redirection methods
     197     *
     198     * @ticket 17588
     199     */
     200    function test_post_redirect_to_method_300() {
     201        $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?post-redirect-to-method=1';
     202
     203        // Test 300 - POST to POST
     204        $res = wp_remote_post( add_query_arg( 'response_code', 300, $url ), array( 'timeout' => 30 ) );
     205        $this->assertEquals( 'POST', wp_remote_retrieve_body( $res ) );
     206
     207        // Test 301 - POST to POST
     208        $res = wp_remote_post( add_query_arg( 'response_code', 301, $url ), array( 'timeout' => 30 ) );
     209        $this->assertEquals( 'POST', wp_remote_retrieve_body( $res ) );
     210
     211        // Test 302 - POST to GET
     212        $res = wp_remote_post( add_query_arg( 'response_code', 302, $url ), array( 'timeout' => 30 ) );
     213        $this->assertEquals( 'GET', wp_remote_retrieve_body( $res ) );
     214
     215        // Test 303 - POST to GET
     216        $res = wp_remote_post( add_query_arg( 'response_code', 303, $url ), array( 'timeout' => 30 ) );
     217        $this->assertEquals( 'GET', wp_remote_retrieve_body( $res ) );
     218
     219        // Test 304 - POST to POST
     220        $res = wp_remote_post( add_query_arg( 'response_code', 304, $url ), array( 'timeout' => 30 ) );
     221        $this->assertEquals( 'POST', wp_remote_retrieve_body( $res ) );
     222    }
     223
    180224}
Note: See TracChangeset for help on using the changeset viewer.