WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (17 months ago)
Author:
SergeyBiryukov
Message:

Tests: First pass at using assertSame() instead of assertEquals() in most of the unit 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.

Props johnbillion, jrf, SergeyBiryukov.
See #38266.

File:
1 edited

Legend:

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

    r46586 r48937  
    99        $link          = 'http://example.com/this-is-a-test-http-url/';
    1010        $relative_link = wp_make_link_relative( $link );
    11         $this->assertEquals( '/this-is-a-test-http-url/', $relative_link );
     11        $this->assertSame( '/this-is-a-test-http-url/', $relative_link );
    1212    }
    1313
     
    1515        $link          = 'https://example.com/this-is-a-test-https-url/';
    1616        $relative_link = wp_make_link_relative( $link );
    17         $this->assertEquals( '/this-is-a-test-https-url/', $relative_link );
     17        $this->assertSame( '/this-is-a-test-https-url/', $relative_link );
    1818    }
    1919
     
    2424        $link          = '//example.com/this-is-a-test-schemeless-url/';
    2525        $relative_link = wp_make_link_relative( $link );
    26         $this->assertEquals( '/this-is-a-test-schemeless-url/', $relative_link );
     26        $this->assertSame( '/this-is-a-test-schemeless-url/', $relative_link );
    2727    }
    2828
     
    3333        $link          = 'https://example.com/this-is-a-test/?redirect=https://example.org/a-different-test-post/';
    3434        $relative_link = wp_make_link_relative( $link );
    35         $this->assertEquals( '/this-is-a-test/?redirect=https://example.org/a-different-test-post/', $relative_link );
     35        $this->assertSame( '/this-is-a-test/?redirect=https://example.org/a-different-test-post/', $relative_link );
    3636    }
    3737
     
    4242        $link          = 'http://example.com';
    4343        $relative_link = wp_make_link_relative( $link );
    44         $this->assertEquals( '', $relative_link );
     44        $this->assertSame( '', $relative_link );
    4545    }
    4646
Note: See TracChangeset for help on using the changeset viewer.