From 717c1c404176c0f0c80a2a2f58e9e6155005b35e Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sun, 28 Feb 2016 01:45:24 +0000 Subject: [PATCH] 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 git-svn-id: https://develop.svn.wordpress.org/trunk@36749 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-http.php | 4 ++++ tests/phpunit/tests/http/http.php | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/wp-includes/class-http.php b/src/wp-includes/class-http.php index d8b703bf9c..838fbe8140 100644 --- a/src/wp-includes/class-http.php +++ b/src/wp-includes/class-http.php @@ -21,6 +21,10 @@ class WP_Http { // Aliases for HTTP response codes. + const HTTP_CONTINUE = 100; + const SWITCHING_PROTOCOLS = 101; + const PROCESSING = 102; + const OK = 200; const CREATED = 201; const ACCEPTED = 202; diff --git a/tests/phpunit/tests/http/http.php b/tests/phpunit/tests/http/http.php index 80b83f9d33..74eda29e21 100644 --- a/tests/phpunit/tests/http/http.php +++ b/tests/phpunit/tests/http/http.php @@ -102,4 +102,20 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase { - ://example.com - assumed path in PHP >= 5.4.7, fails in <5.4.7 */ } + + /** + * @ticket 35426 + */ + public function test_http_response_code_constants() { + global $wp_header_to_desc; + + $ref = new ReflectionClass( 'WP_Http' ); + $constants = $ref->getConstants(); + + // This primes the `$wp_header_to_desc` global: + get_status_header_desc( 200 ); + + $this->assertEquals( array_keys( $wp_header_to_desc ), array_values( $constants ) ); + + } }