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/menu/nav-menu.php

    r48848 r48937  
    4545            'primary' => 1,
    4646        );
    47         $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations );
     47        $this->assertSame( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations );
    4848    }
    4949
     
    6767            'secondary' => 2,
    6868        );
    69         $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations );
     69        $this->assertSame( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations );
    7070    }
    7171
     
    8686
    8787        $expected_nav_menu_locations = $prev_theme_nav_menu_locations;
    88         $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations );
     88        $this->assertSame( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations );
    8989    }
    9090
     
    110110
    111111        $expected_nav_menu_locations = wp_array_slice_assoc( $prev_theme_nav_menu_locations, array_keys( get_registered_nav_menus() ) );
    112         $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations );
     112        $this->assertSame( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations );
    113113    }
    114114
     
    133133            'secondary' => 2,
    134134        );
    135         $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations );
     135        $this->assertSame( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations );
    136136    }
    137137
     
    177177            'main'    => 2,
    178178        );
    179         $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations );
     179        $this->assertSame( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations );
    180180    }
    181181
Note: See TracChangeset for help on using the changeset viewer.