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/link/getAdjacentPost.php

    r47122 r48937  
    5959        $this->go_to( get_permalink( $post_one->ID ) );
    6060
    61         $this->assertEquals( '', get_adjacent_post( true, '', true, 'category' ) );
     61        $this->assertSame( '', get_adjacent_post( true, '', true, 'category' ) );
    6262        $this->assertEquals( $post_three, get_adjacent_post( true, '', false, 'category' ) );
    6363
     
    6565        $this->go_to( get_permalink( $post_two->ID ) );
    6666
    67         $this->assertEquals( '', get_adjacent_post( true, '', true, 'post_tag' ) );
     67        $this->assertSame( '', get_adjacent_post( true, '', true, 'post_tag' ) );
    6868        $this->assertEquals( $post_four, get_adjacent_post( true, '', false, 'post_tag' ) );
    6969
     
    205205
    206206        // Should skip $p2, which belongs to $t.
    207         $this->assertEquals( $p3, $found->ID );
     207        $this->assertSame( $p3, $found->ID );
    208208    }
    209209
     
    242242
    243243        // Should skip $p2, which belongs to $t.
    244         $this->assertEquals( $p3, $found->ID );
     244        $this->assertSame( $p3, $found->ID );
    245245    }
    246246
Note: See TracChangeset for help on using the changeset viewer.