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/filesystem/findFolder.php

    r47198 r48937  
    2121
    2222        $path = $fs->find_folder( '/var/www/wordpress/' );
    23         $this->assertEquals( '/var/www/wordpress/', $path );
     23        $this->assertSame( '/var/www/wordpress/', $path );
    2424
    2525        $path = $fs->find_folder( '/this/directory/doesnt/exist/' );
     
    4545
    4646        $path = $fs->find_folder( '/var/www/example.com/wordpress/' );
    47         $this->assertEquals( '/www/example.com/wordpress/', $path );
     47        $this->assertSame( '/www/example.com/wordpress/', $path );
    4848
    4949        $path = $fs->find_folder( '/var/www/wp.example.com/wordpress/wp-content/' );
    50         $this->assertEquals( '/www/wp.example.com/wordpress/wp-content/', $path );
     50        $this->assertSame( '/www/wp.example.com/wordpress/wp-content/', $path );
    5151
    5252    }
     
    7373
    7474        $path = $fs->abspath( '/var/www/example.com/wp.example.com/wordpress/' );
    75         $this->assertEquals( '/wp.example.com/wordpress/', $path );
     75        $this->assertSame( '/wp.example.com/wordpress/', $path );
    7676
    7777        $path = $fs->abspath( '/var/www/example.com/' );
    78         $this->assertEquals( '/', $path );
     78        $this->assertSame( '/', $path );
    7979
    8080    }
     
    104104        // www.example.com
    105105        $path = $fs->abspath( '/var/www/example.com/www/' );
    106         $this->assertEquals( '/example.com/www/', $path );
     106        $this->assertSame( '/example.com/www/', $path );
    107107
    108108        // sub.example.com
    109109        $path = $fs->abspath( '/var/www/example.com/sub/' );
    110         $this->assertEquals( '/example.com/sub/', $path );
     110        $this->assertSame( '/example.com/sub/', $path );
    111111
    112112        // sub.example.com - Plugins.
    113113        $path = $fs->find_folder( '/var/www/example.com/sub/wp-content/plugins/' );
    114         $this->assertEquals( '/example.com/sub/wp-content/plugins/', $path );
     114        $this->assertSame( '/example.com/sub/wp-content/plugins/', $path );
    115115    }
    116116
Note: See TracChangeset for help on using the changeset viewer.