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/query/stickies.php

    r46586 r48937  
    4141        );
    4242
    43         $this->assertEquals( $expected, $q->posts );
     43        $this->assertSame( $expected, $q->posts );
    4444    }
    4545
     
    4949        $q = $GLOBALS['wp_query'];
    5050
    51         $this->assertEquals( self::$posts[2], $q->posts[0]->ID );
    52         $this->assertEquals( self::$posts[8], $q->posts[1]->ID );
    53         $this->assertEquals( self::$posts[14], $q->posts[2]->ID );
     51        $this->assertSame( self::$posts[2], $q->posts[0]->ID );
     52        $this->assertSame( self::$posts[8], $q->posts[1]->ID );
     53        $this->assertSame( self::$posts[14], $q->posts[2]->ID );
    5454    }
    5555
     
    8383        );
    8484
    85         $this->assertEquals( $expected, wp_list_pluck( $q->posts, 'ID' ) );
     85        $this->assertSame( $expected, wp_list_pluck( $q->posts, 'ID' ) );
    8686    }
    8787
     
    9393        $q = $GLOBALS['wp_query'];
    9494
    95         $this->assertEquals( self::$posts[2], $q->posts[0]->ID );
    96         $this->assertEquals( self::$posts[14], $q->posts[1]->ID );
     95        $this->assertSame( self::$posts[2], $q->posts[0]->ID );
     96        $this->assertSame( self::$posts[14], $q->posts[1]->ID );
    9797        $this->assertNotContains( self::$posts[8], wp_list_pluck( $q->posts, 'ID' ) );
    9898    }
Note: See TracChangeset for help on using the changeset viewer.