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/multisite/siteQuery.php

    r47122 r48937  
    136136            );
    137137
    138             $this->assertEquals( 3, count( $found ) );
     138            $this->assertSame( 3, count( $found ) );
    139139        }
    140140
     
    182182            );
    183183
    184             $this->assertEquals( 2, $found );
     184            $this->assertSame( 2, $found );
    185185        }
    186186
     
    238238            );
    239239
    240             $this->assertEquals( $expected, $found );
     240            $this->assertSame( $expected, $found );
    241241
    242242            $found = $q->query(
     
    249249            );
    250250
    251             $this->assertEquals( array_reverse( $expected ), $found );
     251            $this->assertSame( array_reverse( $expected ), $found );
    252252        }
    253253
     
    699699            );
    700700
    701             $this->assertEquals( $expected, $found );
     701            $this->assertSame( $expected, $found );
    702702        }
    703703
     
    716716            );
    717717
    718             $this->assertEquals( $expected, $found );
     718            $this->assertSame( $expected, $found );
    719719        }
    720720
     
    734734            );
    735735
    736             $this->assertEquals( $expected, $found );
     736            $this->assertSame( $expected, $found );
    737737        }
    738738
     
    815815            );
    816816
    817             $this->assertEquals( $number_of_queries, $wpdb->num_queries );
     817            $this->assertSame( $number_of_queries, $wpdb->num_queries );
    818818        }
    819819
     
    845845                )
    846846            );
    847             $this->assertEquals( $number_of_queries, $wpdb->num_queries );
     847            $this->assertSame( $number_of_queries, $wpdb->num_queries );
    848848        }
    849849
     
    875875                )
    876876            );
    877             $this->assertEquals( $number_of_queries + 1, $wpdb->num_queries );
     877            $this->assertSame( $number_of_queries + 1, $wpdb->num_queries );
    878878        }
    879879
     
    904904
    905905            if ( $strict ) {
    906                 $this->assertEquals( $expected, $found );
     906                $this->assertSame( $expected, $found );
    907907            } else {
    908908                $this->assertEqualSets( $expected, $found );
     
    934934
    935935            // Make sure manually setting total_users doesn't get overwritten.
    936             $this->assertEquals( 1, $q->found_sites );
     936            $this->assertSame( 1, $q->found_sites );
    937937        }
    938938
Note: See TracChangeset for help on using the changeset viewer.