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/xmlrpc/wp/getComment.php

    r47122 r48937  
    3737        $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'username', 'password', self::$parent_comment_id ) );
    3838        $this->assertIXRError( $result );
    39         $this->assertEquals( 403, $result->code );
     39        $this->assertSame( 403, $result->code );
    4040    }
    4141
     
    4545        $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'contributor', 'contributor', self::$parent_comment_id ) );
    4646        $this->assertIXRError( $result );
    47         $this->assertEquals( 403, $result->code );
     47        $this->assertSame( 403, $result->code );
    4848    }
    4949
     
    7777        $this->assertEquals( self::$parent_comment_id, $result['comment_id'] );
    7878        $this->assertEquals( 0, $result['parent'] );
    79         $this->assertEquals( self::$parent_comment_data['comment_content'], $result['content'] );
     79        $this->assertSame( self::$parent_comment_data['comment_content'], $result['content'] );
    8080        $this->assertEquals( self::$post_id, $result['post_id'] );
    81         $this->assertEquals( self::$parent_comment_data['comment_author'], $result['author'] );
    82         $this->assertEquals( self::$parent_comment_data['comment_author_url'], $result['author_url'] );
    83         $this->assertEquals( self::$parent_comment_data['comment_author_email'], $result['author_email'] );
     81        $this->assertSame( self::$parent_comment_data['comment_author'], $result['author'] );
     82        $this->assertSame( self::$parent_comment_data['comment_author_url'], $result['author_url'] );
     83        $this->assertSame( self::$parent_comment_data['comment_author_email'], $result['author_email'] );
    8484    }
    8585
     
    9999        $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', 123456789 ) );
    100100        $this->assertIXRError( $result );
    101         $this->assertEquals( 404, $result->code );
     101        $this->assertSame( 404, $result->code );
    102102    }
    103103}
Note: See TracChangeset for help on using the changeset viewer.