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

    r47727 r48937  
    4242     */
    4343    public function test_non_current_page() {
    44         $this->assertEquals( get_permalink( self::$post_id ), wp_get_canonical_url( self::$post_id ) );
     44        $this->assertSame( get_permalink( self::$post_id ), wp_get_canonical_url( self::$post_id ) );
    4545    }
    4646
     
    6666        );
    6767
    68         $this->assertEquals( $expected, wp_get_canonical_url( self::$post_id ) );
     68        $this->assertSame( $expected, wp_get_canonical_url( self::$post_id ) );
    6969    }
    7070
     
    8888        $expected = trailingslashit( get_permalink( self::$post_id ) ) . user_trailingslashit( $page, 'single_paged' );
    8989
    90         $this->assertEquals( $expected, wp_get_canonical_url( self::$post_id ) );
     90        $this->assertSame( $expected, wp_get_canonical_url( self::$post_id ) );
    9191    }
    9292
     
    114114        );
    115115
    116         $this->assertEquals( $expected, wp_get_canonical_url( self::$post_id ) );
     116        $this->assertSame( $expected, wp_get_canonical_url( self::$post_id ) );
    117117    }
    118118
     
    138138        $expected = user_trailingslashit( trailingslashit( get_permalink( self::$post_id ) ) . $wp_rewrite->comments_pagination_base . '-' . $cpage, 'commentpaged' ) . '#comments';
    139139
    140         $this->assertEquals( $expected, wp_get_canonical_url( self::$post_id ) );
     140        $this->assertSame( $expected, wp_get_canonical_url( self::$post_id ) );
    141141    }
    142142
     
    149149        remove_filter( 'get_canonical_url', array( $this, 'canonical_url_filter' ) );
    150150
    151         $this->assertEquals( $this->canonical_url_filter(), $canonical_url );
     151        $this->assertSame( $this->canonical_url_filter(), $canonical_url );
    152152    }
    153153
Note: See TracChangeset for help on using the changeset viewer.