Make WordPress Core

Changeset 38757


Ignore:
Timestamp:
10/08/2016 12:29:20 AM (8 years ago)
Author:
johnbillion
Message:

HTTP API: Convert the POST redirect test to use a dataProvider in order for its speed to be more accurately measured.

See #38237

File:
1 edited

Legend:

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

    r38429 r38757  
    270270     * Test POST redirection methods
    271271     *
     272     * @dataProvider data_post_redirect_to_method_300
     273     *
    272274     * @ticket 17588
    273275     */
    274     function test_post_redirect_to_method_300() {
     276    function test_post_redirect_to_method_300( $response_code, $method ) {
    275277        $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?post-redirect-to-method=1';
    276278
    277         // Test 300 - POST to POST
    278         $res = wp_remote_post( add_query_arg( 'response_code', 300, $url ), array( 'timeout' => 30 ) );
    279         $this->assertEquals( 'POST', wp_remote_retrieve_body( $res ) );
    280 
    281         // Test 301 - POST to POST
    282         $res = wp_remote_post( add_query_arg( 'response_code', 301, $url ), array( 'timeout' => 30 ) );
    283         $this->assertEquals( 'POST', wp_remote_retrieve_body( $res ) );
    284 
    285         // Test 302 - POST to GET
    286         $res = wp_remote_post( add_query_arg( 'response_code', 302, $url ), array( 'timeout' => 30 ) );
    287         $this->assertEquals( 'GET', wp_remote_retrieve_body( $res ) );
    288 
    289         // Test 303 - POST to GET
    290         $res = wp_remote_post( add_query_arg( 'response_code', 303, $url ), array( 'timeout' => 30 ) );
    291         $this->assertEquals( 'GET', wp_remote_retrieve_body( $res ) );
     279        $res = wp_remote_post( add_query_arg( 'response_code', $response_code, $url ), array( 'timeout' => 30 ) );
     280        $this->assertEquals( $method, wp_remote_retrieve_body( $res ) );
     281    }
     282
     283    public function data_post_redirect_to_method_300() {
     284        return array(
     285            // Test 300 - POST to POST
     286            array(
     287                300,
     288                'POST',
     289            ),
     290            // Test 301 - POST to POST
     291            array(
     292                301,
     293                'POST',
     294            ),
     295            // Test 302 - POST to GET
     296            array(
     297                302,
     298                'GET',
     299            ),
     300            // Test 303 - POST to GET
     301            array(
     302                303,
     303                'GET',
     304            ),
     305        );
    292306    }
    293307
Note: See TracChangeset for help on using the changeset viewer.