Skip to content

Commit 4b5efee

Browse files
Tests: Move the HTTP response codes test for consistency.
While the test was originally written to verify that the `WP_Http` class has all the HTTP response codes as constants, it ensures that the constants match the response codes stored in the `$wp_header_to_desc` global used by the `get_status_header_desc()` function, so the latter's unit test file appears to be the logical placement. Follow-up to [36749], [46107]. Props pbearne, khokansardar, SergeyBiryukov. Fixes #65527. git-svn-id: https://develop.svn.wordpress.org/trunk@62593 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 2303172 commit 4b5efee

2 files changed

Lines changed: 18 additions & 17 deletions

File tree

tests/phpunit/tests/functions/getStatusHeaderDesc.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,22 @@ public function data_get_status_header_desc() {
4141
array( 'random', '' ),
4242
);
4343
}
44+
45+
/**
46+
* Tests that the HTTP response codes stored in the `$wp_header_to_desc` global
47+
* match the constants in the WP_Http class.
48+
*
49+
* @ticket 35426
50+
*/
51+
public function test_http_response_code_constants() {
52+
global $wp_header_to_desc;
53+
54+
$ref = new ReflectionClass( 'WP_Http' );
55+
$constants = $ref->getConstants();
56+
57+
// This primes the `$wp_header_to_desc` global:
58+
get_status_header_desc( 200 );
59+
60+
$this->assertSame( array_keys( $wp_header_to_desc ), array_values( $constants ) );
61+
}
4462
}

tests/phpunit/tests/http/http.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -277,23 +277,6 @@ public function data_wp_parse_url_with_component() {
277277
);
278278
}
279279

280-
/**
281-
* @ticket 35426
282-
*
283-
* @covers ::get_status_header_desc
284-
*/
285-
public function test_http_response_code_constants() {
286-
global $wp_header_to_desc;
287-
288-
$ref = new ReflectionClass( 'WP_Http' );
289-
$constants = $ref->getConstants();
290-
291-
// This primes the `$wp_header_to_desc` global:
292-
get_status_header_desc( 200 );
293-
294-
$this->assertSame( array_keys( $wp_header_to_desc ), array_values( $constants ) );
295-
}
296-
297280
/**
298281
* @ticket 37768
299282
*

0 commit comments

Comments
 (0)