Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

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

    r46682 r47122  
    3333        // Disable all transports aside from this one.
    3434        foreach ( array( 'curl', 'streams', 'fsockopen' ) as $t ) {
    35             remove_filter( "use_{$t}_transport", '__return_false' ); // Just strip them all
     35            remove_filter( "use_{$t}_transport", '__return_false' );  // Just strip them all...
    3636            if ( $t !== $this->transport ) {
    37                 add_filter( "use_{$t}_transport", '__return_false' ); // and add it back if need be..
     37                add_filter( "use_{$t}_transport", '__return_false' ); // ...and add it back if need be.
    3838            }
    3939        }
     
    5353
    5454    function test_redirect_on_301() {
    55         // 5 : 5 & 301
     55        // 5 : 5 & 301.
    5656        $res = wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 5 ) );
    5757
     
    6262
    6363    function test_redirect_on_302() {
    64         // 5 : 5 & 302
     64        // 5 : 5 & 302.
    6565        $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 5 ) );
    6666
     
    7474     */
    7575    function test_redirect_on_301_no_redirect() {
    76         // 5 > 0 & 301
     76        // 5 > 0 & 301.
    7777        $res = wp_remote_request( $this->redirection_script . '?code=301&rt=' . 5, array( 'redirection' => 0 ) );
    7878
     
    8686     */
    8787    function test_redirect_on_302_no_redirect() {
    88         // 5 > 0 & 302
     88        // 5 > 0 & 302.
    8989        $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) );
    9090
     
    9595
    9696    function test_redirections_equal() {
    97         // 5 - 5
     97        // 5 - 5.
    9898        $res = wp_remote_request( $this->redirection_script . '?rt=' . 5, array( 'redirection' => 5 ) );
    9999
     
    104104
    105105    function test_no_head_redirections() {
    106         // No redirections on HEAD request:
     106        // No redirections on HEAD request.
    107107        $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 1, array( 'method' => 'HEAD' ) );
    108108
     
    116116     */
    117117    function test_redirect_on_head() {
    118         // Redirections on HEAD request when Requested
     118        // Redirections on HEAD request when Requested.
    119119        $res = wp_remote_request(
    120120            $this->redirection_script . '?rt=' . 5,
     
    131131
    132132    function test_redirections_greater() {
    133         // 10 > 5
     133        // 10 > 5.
    134134        $res = wp_remote_request( $this->redirection_script . '?rt=' . 10, array( 'redirection' => 5 ) );
    135135
     
    139139
    140140    function test_redirections_greater_edgecase() {
    141         // 6 > 5 (close edgecase)
     141        // 6 > 5 (close edge case).
    142142        $res = wp_remote_request( $this->redirection_script . '?rt=' . 6, array( 'redirection' => 5 ) );
    143143
     
    147147
    148148    function test_redirections_less_edgecase() {
    149         // 4 < 5 (close edgecase)
     149        // 4 < 5 (close edge case).
    150150        $res = wp_remote_request( $this->redirection_script . '?rt=' . 4, array( 'redirection' => 5 ) );
    151151
     
    158158     */
    159159    function test_redirections_zero_redirections_specified() {
    160         // 0 redirections asked for, Should return the document?
     160        // 0 redirections asked for, should return the document?
    161161        $res = wp_remote_request( $this->redirection_script . '?code=302&rt=' . 5, array( 'redirection' => 0 ) );
    162162
     
    167167
    168168    /**
    169      * Do not redirect on non 3xx status codes
     169     * Do not redirect on non 3xx status codes.
    170170     *
    171171     * @ticket 16889
    172172     */
    173173    function test_location_header_on_201() {
    174         // Prints PASS on initial load, FAIL if the client follows the specified redirection
     174        // Prints PASS on initial load, FAIL if the client follows the specified redirection.
    175175        $res = wp_remote_request( $this->redirection_script . '?201-location=true' );
    176176
     
    181181
    182182    /**
    183      * Test handling of PUT requests on redirects
     183     * Test handling of PUT requests on redirects.
    184184     *
    185185     * @ticket 16889
     
    188188        $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?201-location=1';
    189189
    190         // Test 301 - POST to POST
     190        // Test 301 - POST to POST.
    191191        $res = wp_remote_request(
    192192            $url,
     
    206206     */
    207207    function test_send_headers() {
    208         // Test that the headers sent are received by the server
     208        // Test that the headers sent are received by the server.
    209209        $headers = array(
    210210            'test1' => 'test',
     
    231231        // cURL/HTTP Extension Note: Will never pass, cURL does not pass headers with an empty value.
    232232        // Should it be that empty headers with empty values are NOT sent?
    233         //$this->assertTrue( isset($headers['test3']) && '' === $headers['test3'] );
     233        // $this->assertTrue( isset( $headers['test3'] ) && '' === $headers['test3'] );
    234234    }
    235235
     
    243243                'timeout' => 30,
    244244            )
    245         ); //Auto generate the filename.
     245        ); // Auto generate the filename.
    246246
    247247        // Cleanup before we assert, as it'll return early.
     
    254254        $this->assertNotWPError( $res );
    255255        $this->assertEquals( '', $res['body'] ); // The body should be empty.
    256         $this->assertEquals( $size, $res['headers']['content-length'] ); // Check the headers are returned (and the size is the same..)
    257         $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters
    258         $this->assertStringStartsWith( get_temp_dir(), $res['filename'] ); // Check it's saving within the temp dir
     256        $this->assertEquals( $size, $res['headers']['content-length'] );   // Check the headers are returned (and the size is the same).
     257        $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters.
     258        $this->assertStringStartsWith( get_temp_dir(), $res['filename'] ); // Check it's saving within the temp directory.
    259259    }
    260260
     
    272272                'limit_response_size' => $size,
    273273            )
    274         ); //Auto generate the filename.
     274        ); // Auto generate the filename.
    275275
    276276        // Cleanup before we assert, as it'll return early.
     
    282282        $this->skipTestOnTimeout( $res );
    283283        $this->assertNotWPError( $res );
    284         $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters
    285 
    286     }
    287 
    288     /**
    289      * Tests Limiting the response size when returning strings
     284        $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters.
     285
     286    }
     287
     288    /**
     289     * Tests limiting the response size when returning strings.
    290290     *
    291291     * @ticket 31172
     
    309309
    310310    /**
    311      * Test POST redirection methods
     311     * Test POST redirection methods.
    312312     *
    313313     * @dataProvider data_post_redirect_to_method_300
     
    326326    public function data_post_redirect_to_method_300() {
    327327        return array(
    328             // Test 300 - POST to POST
     328            // Test 300 - POST to POST.
    329329            array(
    330330                300,
    331331                'POST',
    332332            ),
    333             // Test 301 - POST to POST
     333            // Test 301 - POST to POST.
    334334            array(
    335335                301,
    336336                'POST',
    337337            ),
    338             // Test 302 - POST to GET
     338            // Test 302 - POST to GET.
    339339            array(
    340340                302,
    341341                'GET',
    342342            ),
    343             // Test 303 - POST to GET
     343            // Test 303 - POST to GET.
    344344            array(
    345345                303,
     
    350350
    351351    /**
    352      * Test HTTP Requests using an IP url, with a HOST header specified
     352     * Test HTTP Requests using an IP URL, with a HOST header specified.
    353353     *
    354354     * @ticket 24182
     
    373373
    374374    /**
    375      * Test HTTP requests where SSL verification is disabled but the CA bundle is still populated
     375     * Test HTTP requests where SSL verification is disabled but the CA bundle is still populated.
    376376     *
    377377     * @ticket 33978
     
    395395
    396396    /**
    397      * Test HTTP Redirects with multiple Location headers specified
     397     * Test HTTP Redirects with multiple Location headers specified.
    398398     *
    399399     * @ticket 16890
     
    415415
    416416    /**
    417      * Test HTTP Cookie handling
     417     * Test HTTP Cookie handling.
    418418     *
    419419     * @ticket 21182
     
    429429
    430430    /**
    431      * Test if HTTPS support works
     431     * Test if HTTPS support works.
    432432     *
    433433     * @group ssl
Note: See TracChangeset for help on using the changeset viewer.