Make WordPress Core


Ignore:
Timestamp:
12/14/2025 08:10:25 AM (2 months ago)
Author:
westonruter
Message:

REST API: Use valid host in unit tests for URL Details endpoint.

This ensures that the url parameter is not marked as invalid due to wp_http_validate_url() failing because of a gethostbyname() failure.

Follow-up to [51973].

Props westonruter, swissspidy.
See #54358.
Fixes #64412.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/wpRestUrlDetailsController.php

    r60729 r61377  
    4444     * URL placeholder.
    4545     *
     46     * Even though the request is being intercepted with a mocked response, it is not fully bypassing the network. The
     47     * REST API endpoint is validating the `url` parameter with `wp_http_validate_url()` which includes a call to
     48     * `gethostbyname()`. So the domain used in the placeholder URL must be valid to ensure it passes a validity check.
     49     *
    4650     * @since 5.9.0
    4751     *
    4852     * @var string
    4953     */
    50     const URL_PLACEHOLDER = 'https://placeholder-site.com';
     54    const URL_PLACEHOLDER = 'https://example.com';
    5155
    5256    /**
     
    130134            array(
    131135                'title'       => 'Example Website — - with encoded content.',
    132                 'icon'        => 'https://placeholder-site.com/favicon.ico?querystringaddedfortesting',
     136                'icon'        => 'https://example.com/favicon.ico?querystringaddedfortesting',
    133137                'description' => 'Example description text here. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore.',
    134                 'image'       => 'https://placeholder-site.com/images/home/screen-themes.png?3',
     138                'image'       => 'https://example.com/images/home/screen-themes.png?3',
    135139            ),
    136140            $data
     
    445449        $this->assertSame( 418, $data['status'], 'Response "status" is not 418' );
    446450
    447         $expected = 'Response for URL https://placeholder-site.com altered via rest_prepare_url_details filter';
     451        $expected = 'Response for URL https://example.com altered via rest_prepare_url_details filter';
    448452        $this->assertSame( $expected, $data['response'], 'Response "response" is not "' . $expected . '"' );
    449453    }
Note: See TracChangeset for help on using the changeset viewer.