Make WordPress Core


Ignore:
Timestamp:
12/14/2022 01:26:39 AM (2 years ago)
Author:
peterwilsoncc
Message:

Built/Test tools, HTTP API: Refactor test for multiple location headers.

Remove wordpress.org as an external dependency testing WP_HTTP::handle_redirects().

This refactors and reenables an existing test to call the WP_HTTP::handle_redirects() method directly with a mocked array of HTTP headers containing multiple location headers.

The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.

Follow up to [54955].

Props SergeyBiryukov, dd32, peterwilsoncc.
Fixes #57306.
See #56793.

File:
1 edited

Legend:

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

    r54955 r54968  
    437437
    438438    /**
    439      * Test HTTP Redirects with multiple Location headers specified.
    440      *
    441      * This test has been disabled due to api.wordpress.org failing to
    442      * send two Location headers. See #57306.
    443      *
    444      * @ticket 16890
    445      *
    446      * @covers ::wp_remote_head
    447      * @covers ::wp_remote_retrieve_header
    448      * @covers ::wp_remote_get
    449      * @covers ::wp_remote_retrieve_body
    450      */
    451     public function disabled_test_multiple_location_headers() {
    452         $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?multiple-location-headers=1';
    453         $res = wp_remote_head( $url, array( 'timeout' => 30 ) );
    454 
    455         $this->skipTestOnTimeout( $res );
    456         $this->assertIsArray( wp_remote_retrieve_header( $res, 'location' ) );
    457         $this->assertCount( 2, wp_remote_retrieve_header( $res, 'location' ) );
    458 
    459         $res = wp_remote_get( $url, array( 'timeout' => 30 ) );
    460 
    461         $this->skipTestOnTimeout( $res );
    462         $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) );
    463 
    464     }
    465 
    466     /**
    467439     * Test HTTP Cookie handling.
    468440     *
Note: See TracChangeset for help on using the changeset viewer.