Make WordPress Core

Changeset 58070


Ignore:
Timestamp:
05/01/2024 06:54:36 PM (4 weeks ago)
Author:
SergeyBiryukov
Message:

Tests: Use assertSame() in wp_validate_redirect() tests.

This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using assertSame() should generally be preferred to assertEquals() where appropriate, to make the tests more reliable.

Follow-up to [36444].

Props costdev.
See #60706.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/redirect.php

    r57735 r58070  
    7777     *
    7878     * @covers ::wp_validate_redirect
     79     *
     80     * @param string $url      Redirect requested.
     81     * @param string $expected Expected destination.
    7982     */
    8083    public function test_wp_validate_redirect_valid_url( $url, $expected ) {
     
    102105     *
    103106     * @covers ::wp_validate_redirect
    104      */
    105     public function test_wp_validate_redirect_invalid_url( $url ) {
    106         $this->assertEquals( false, wp_validate_redirect( $url, false ) );
     107     *
     108     * @param string       $url      Redirect requested.
     109     * @param string|false $expected Optional. Expected destination. Default false.
     110     */
     111    public function test_wp_validate_redirect_invalid_url( $url, $expected = false ) {
     112        $this->assertSame( $expected, wp_validate_redirect( $url, false ) );
    107113    }
    108114
     
    110116        return array(
    111117            // parse_url() fails.
    112             array( '' ),
     118            array( '', '' ),
    113119            array( 'http://:' ),
    114120
     
    180186     *
    181187     * @covers ::wp_validate_redirect
     188     *
     189     * @param string $current_uri Current URI (i.e. path and query string only).
     190     * @param string $url         Redirect requested.
     191     * @param string $expected    Expected destination.
    182192     */
    183193    public function test_wp_validate_redirect_relative_url( $current_uri, $url, $expected ) {
Note: See TracChangeset for help on using the changeset viewer.