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/post/getPageChildren.php

    r46586 r48937  
    7575        $expected = array( 100, 101, 103, 102, 106, 107, 108, 105 );
    7676        $actual   = get_page_children( 0, $this->pages );
    77         $this->assertEquals( $expected, wp_list_pluck( $actual, 'ID' ) );
     77        $this->assertSame( $expected, wp_list_pluck( $actual, 'ID' ) );
    7878    }
    7979
     
    8181        $expected = array( 106, 107, 108 );
    8282        $actual   = get_page_children( 102, $this->pages );
    83         $this->assertEquals( $expected, wp_list_pluck( $actual, 'ID' ) );
     83        $this->assertSame( $expected, wp_list_pluck( $actual, 'ID' ) );
    8484    }
    8585
    8686    public function test_page_id_that_is_a_leaf_should_return_empty_array() {
    8787        $actual = get_page_children( 103, $this->pages );
    88         $this->assertEquals( array(), $actual );
     88        $this->assertSame( array(), $actual );
    8989    }
    9090
    9191    public function test_nonzero_page_id_not_matching_any_actual_post_id_should_return_empty_array() {
    9292        $actual = get_page_children( 200, $this->pages );
    93         $this->assertEquals( array(), $actual );
     93        $this->assertSame( array(), $actual );
    9494    }
    9595}
Note: See TracChangeset for help on using the changeset viewer.