Make WordPress Core

Changeset 36749


Ignore:
Timestamp:
02/28/2016 01:45:24 AM (9 years ago)
Author:
johnbillion
Message:

HTTP API: Add the missing 1xx HTTP response codes as constants of the WP_Http class, and add tests to ensure all available response codes are covered.

Fixes #36294

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-http.php

    r36416 r36749  
    2222
    2323    // Aliases for HTTP response codes.
     24    const HTTP_CONTINUE                   = 100;
     25    const SWITCHING_PROTOCOLS             = 101;
     26    const PROCESSING                      = 102;
     27
    2428    const OK                              = 200;
    2529    const CREATED                         = 201;
  • trunk/tests/phpunit/tests/http/http.php

    r35369 r36749  
    103103        */
    104104    }
     105
     106    /**
     107     * @ticket 35426
     108     */
     109    public function test_http_response_code_constants() {
     110        global $wp_header_to_desc;
     111
     112        $ref = new ReflectionClass( 'WP_Http' );
     113        $constants = $ref->getConstants();
     114
     115        // This primes the `$wp_header_to_desc` global:
     116        get_status_header_desc( 200 );
     117
     118        $this->assertEquals( array_keys( $wp_header_to_desc ), array_values( $constants ) );
     119
     120    }
    105121}
Note: See TracChangeset for help on using the changeset viewer.