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/rewrite/numericSlugs.php

    r47122 r48937  
    7676        );
    7777
    78         $this->assertEquals( '2015', url_to_postid( get_permalink( '2015' ) ) );
     78        $this->assertSame( 2015, url_to_postid( get_permalink( '2015' ) ) );
    7979    }
    8080
     
    110110        );
    111111
    112         $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     112        $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) );
    113113    }
    114114
     
    146146        );
    147147
    148         $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     148        $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) );
    149149    }
    150150
     
    182182        );
    183183
    184         $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     184        $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) );
    185185    }
    186186
     
    216216        );
    217217
    218         $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     218        $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) );
    219219    }
    220220
     
    250250        );
    251251
    252         $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     252        $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) );
    253253    }
    254254
     
    286286        );
    287287
    288         $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     288        $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) );
    289289    }
    290290
     
    320320        );
    321321
    322         $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) );
     322        $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) );
    323323    }
    324324
Note: See TracChangeset for help on using the changeset viewer.