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/output.php

    r47122 r48937  
    6060        $this->assertNull( the_post() );
    6161
    62         $this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
     62        $this->assertSame( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
    6363    }
    6464
     
    8888        $this->assertNull( the_post() );
    8989
    90         $this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
     90        $this->assertSame( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
    9191    }
    9292
     
    126126        $this->assertNull( the_post() );
    127127
    128         $this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
     128        $this->assertSame( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
    129129    }
    130130
     
    148148        $this->assertNull( the_post() );
    149149
    150         $this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
     150        $this->assertSame( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
    151151
    152152        kses_remove_filters();
     
    172172        $this->assertNull( the_post() );
    173173
    174         $this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
     174        $this->assertSame( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
    175175
    176176        kses_remove_filters();
Note: See TracChangeset for help on using the changeset viewer.