Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (6 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/multisite/networkQuery.php

    r46586 r48937  
    7171                        );
    7272
    73                         $this->assertEquals( 3, count( $found ) );
     73                        $this->assertSame( 3, count( $found ) );
    7474                }
    7575
    … …  
    8686                        );
    8787
    88                         $this->assertEquals( $expected, $found );
     88                        $this->assertSame( $expected, $found );
    8989
    9090                        $found = $q->query(
    … …  
    9696                        );
    9797
    98                         $this->assertEquals( array_reverse( $expected ), $found );
     98                        $this->assertSame( array_reverse( $expected ), $found );
    9999                }
    100100
    … …  
    139139                        );
    140140
    141                         $this->assertEquals( 2, $found );
     141                        $this->assertSame( 2, $found );
    142142                }
    143143
    … …  
    436436                        );
    437437
    438                         $this->assertEquals( $expected, $found );
     438                        $this->assertSame( $expected, $found );
    439439                }
    440440
    … …  
    463463                        );
    464464
    465                         $this->assertEquals( $number_of_queries, $wpdb->num_queries );
     465                        $this->assertSame( $number_of_queries, $wpdb->num_queries );
    466466                }
    467467
    … …  
    492492                                )
    493493                        );
    494                         $this->assertEquals( $number_of_queries, $wpdb->num_queries );
     494                        $this->assertSame( $number_of_queries, $wpdb->num_queries );
    495495                }
    496496
    … …  
    521521                                )
    522522                        );
    523                         $this->assertEquals( $number_of_queries + 1, $wpdb->num_queries );
     523                        $this->assertSame( $number_of_queries + 1, $wpdb->num_queries );
    524524                }
    525525
    … …  
    547547
    548548                        // Make sure manually setting total_users doesn't get overwritten.
    549                         $this->assertEquals( 1, $q->found_networks );
     549                        $this->assertSame( 1, $q->found_networks );
    550550                }
    551551
Note: See TracChangeset for help on using the changeset viewer.