Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (4 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/post/getPageUri.php

    r47122 r48937  
    1717
    1818        // Dummy assertion. If this test fails, it will actually error out on an E_WARNING.
    19         $this->assertEquals( 'get-page-uri-post-name', get_page_uri( $post_array ) );
     19        $this->assertSame( 'get-page-uri-post-name', get_page_uri( $post_array ) );
    2020    }
    2121
     
    4242
    4343        // Check the parent for good measure.
    44         $this->assertEquals( 'parent', get_page_uri( $parent_id ) );
     44        $this->assertSame( 'parent', get_page_uri( $parent_id ) );
    4545
    4646        // Try the child normally.
    47         $this->assertEquals( 'parent/child', get_page_uri( $child_id ) );
     47        $this->assertSame( 'parent/child', get_page_uri( $child_id ) );
    4848
    4949        // Now delete the parent from the database and check.
    5050        wp_delete_post( $parent_id, true );
    51         $this->assertEquals( 'child', get_page_uri( $child_id ) );
     51        $this->assertSame( 'child', get_page_uri( $child_id ) );
    5252    }
    5353
     
    7272        );
    7373
    74         $this->assertEquals( 'child', get_page_uri( $child_id ) );
     74        $this->assertSame( 'child', get_page_uri( $child_id ) );
    7575    }
    7676
     
    8787        $post    = get_post( $post_id );
    8888        $this->go_to( get_permalink( $post_id ) );
    89         $this->assertEquals( 'blood-orange-announces-summer-tour-dates', get_page_uri() );
     89        $this->assertSame( 'blood-orange-announces-summer-tour-dates', get_page_uri() );
    9090    }
    9191}
Note: See TracChangeset for help on using the changeset viewer.