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/xmlrpc/mt/getRecentPostTitles.php

    r46586 r48937  
    99        $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'username', 'password' ) );
    1010        $this->assertIXRError( $result );
    11         $this->assertEquals( 403, $result->code );
     11        $this->assertSame( 403, $result->code );
    1212    }
    1313
     
    1717        $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) );
    1818        $this->assertIXRError( $result );
    19         $this->assertEquals( 500, $result->code );
     19        $this->assertSame( 500, $result->code );
    2020    }
    2121
     
    2727        $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) );
    2828        $this->assertNotIXRError( $result );
    29         $this->assertEquals( 0, count( $result ) );
     29        $this->assertSame( 0, count( $result ) );
    3030    }
    3131
     
    4545            $this->assertInstanceOf( 'IXR_Date', $result['date_created_gmt'] );
    4646
    47             $this->assertEquals( strtotime( $post->post_date ), $result['dateCreated']->getTimestamp() );
    48             $this->assertEquals( $date_gmt, $result['date_created_gmt']->getTimestamp() );
     47            $this->assertSame( strtotime( $post->post_date ), $result['dateCreated']->getTimestamp() );
     48            $this->assertSame( $date_gmt, $result['date_created_gmt']->getTimestamp() );
    4949        }
    5050    }
Note: See TracChangeset for help on using the changeset viewer.