Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (4 years 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/admin/includesFile.php

    r46586 r48937  
    1414        $siteurl = get_option( 'siteurl' );
    1515        $sfn     = $_SERVER['SCRIPT_FILENAME'];
    16         $this->assertEquals( str_replace( '\\', '/', ABSPATH ), get_home_path() );
     16        $this->assertSame( str_replace( '\\', '/', ABSPATH ), get_home_path() );
    1717
    1818        update_option( 'home', 'http://localhost' );
     
    2020
    2121        $_SERVER['SCRIPT_FILENAME'] = 'D:\root\vhosts\site\httpdocs\wp\wp-admin\options-permalink.php';
    22         $this->assertEquals( 'D:/root/vhosts/site/httpdocs/', get_home_path() );
     22        $this->assertSame( 'D:/root/vhosts/site/httpdocs/', get_home_path() );
    2323
    2424        $_SERVER['SCRIPT_FILENAME'] = '/Users/foo/public_html/trunk/wp/wp-admin/options-permalink.php';
    25         $this->assertEquals( '/Users/foo/public_html/trunk/', get_home_path() );
     25        $this->assertSame( '/Users/foo/public_html/trunk/', get_home_path() );
    2626
    2727        $_SERVER['SCRIPT_FILENAME'] = 'S:/home/wordpress/trunk/wp/wp-admin/options-permalink.php';
    28         $this->assertEquals( 'S:/home/wordpress/trunk/', get_home_path() );
     28        $this->assertSame( 'S:/home/wordpress/trunk/', get_home_path() );
    2929
    3030        update_option( 'home', $home );
     
    4141        $error = download_url( 'test_download_url_non_200' );
    4242        $this->assertWPError( $error );
    43         $this->assertEquals(
     43        $this->assertSame(
    4444            array(
    4545                'code' => 418,
     
    5353        $error = download_url( 'test_download_url_non_200' );
    5454        $this->assertWPError( $error );
    55         $this->assertEquals(
     55        $this->assertSame(
    5656            array(
    5757                'code' => 418,
Note: See TracChangeset for help on using the changeset viewer.