Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (5 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/user/countUsers.php

    r47122 r48937  
    5353        $count = count_users( $strategy );
    5454
    55         $this->assertEquals( 8, $count['total_users'] );
     55        $this->assertSame( 8, $count['total_users'] );
    5656        $this->assertEquals(
    5757            array(
     
    133133        $count = count_users( $strategy );
    134134
    135         $this->assertEquals( 8, $count['total_users'] );
     135        $this->assertSame( 8, $count['total_users'] );
    136136        $this->assertEquals(
    137137            array(
     
    151151        restore_current_blog();
    152152
    153         $this->assertEquals( 2, $count['total_users'] );
     153        $this->assertSame( 2, $count['total_users'] );
    154154        $this->assertEquals(
    155155            array(
     
    166166        restore_current_blog();
    167167
    168         $this->assertEquals( 2, $count['total_users'] );
     168        $this->assertSame( 2, $count['total_users'] );
    169169        $this->assertEquals(
    170170            array(
     
    228228        get_userdata( $editor )->add_role( 'author' );
    229229
    230         $this->assertEquals(
     230        $this->assertSame(
    231231            array(
    232232                'editor',
     
    239239        $count = count_users( $strategy );
    240240
    241         $this->assertEquals( 3, $count['total_users'] );
     241        $this->assertSame( 3, $count['total_users'] );
    242242        $this->assertEquals(
    243243            array(
Note: See TracChangeset for help on using the changeset viewer.