Make WordPress Core


Ignore:
Timestamp:
06/30/2026 04:36:25 PM (4 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions/getStatusHeaderDesc.php

    r57735 r62593  
    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}
Note: See TracChangeset for help on using the changeset viewer.