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/formatting/MapDeep.php

    r46586 r48937  
    88
    99    public function test_map_deep_with_any_function_over_empty_array_should_return_empty_array() {
    10         $this->assertEquals( array(), map_deep( array(), array( $this, 'append_baba' ) ) );
     10        $this->assertSame( array(), map_deep( array(), array( $this, 'append_baba' ) ) );
    1111    }
    1212
    1313    public function test_map_deep_should_map_each_element_of_array_one_level_deep() {
    14         $this->assertEquals(
     14        $this->assertSame(
    1515            array(
    1616                'ababa',
     
    2828
    2929    public function test_map_deep_should_map_each_element_of_array_two_levels_deep() {
    30         $this->assertEquals(
     30        $this->assertSame(
    3131            array(
    3232                'ababa',
     
    6868
    6969    public function test_map_deep_should_apply_the_function_to_a_string() {
    70         $this->assertEquals( 'xbaba', map_deep( 'x', array( $this, 'append_baba' ) ) );
     70        $this->assertSame( 'xbaba', map_deep( 'x', array( $this, 'append_baba' ) ) );
    7171    }
    7272
    7373    public function test_map_deep_should_apply_the_function_to_an_integer() {
    74         $this->assertEquals( '5baba', map_deep( 5, array( $this, 'append_baba' ) ) );
     74        $this->assertSame( '5baba', map_deep( 5, array( $this, 'append_baba' ) ) );
    7575    }
    7676
     
    158158            'var1' => 'x',
    159159        );
    160         $this->assertEquals(
     160        $this->assertSame(
    161161            array(
    162162                'var0' => 'ababa',
Note: See TracChangeset for help on using the changeset viewer.