Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (5 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/editComment.php

    r46586 r48937  
    6060        $result = $this->myxmlrpcserver->wp_editComment( array( 1, 'author', 'author', $comment_id, array( 'status' => 'hold' ) ) );
    6161        $this->assertIXRError( $result );
    62         $this->assertEquals( 403, $result->code );
    63         $this->assertEquals( __( 'Sorry, you are not allowed to moderate or edit this comment.' ), $result->message );
     62        $this->assertSame( 403, $result->code );
     63        $this->assertSame( __( 'Sorry, you are not allowed to moderate or edit this comment.' ), $result->message );
    6464    }
    6565
     
    7878        $comment_id   = wp_insert_comment( $comment_data );
    7979
    80         $this->assertEquals( '1', get_comment( $comment_id )->comment_approved );
     80        $this->assertSame( '1', get_comment( $comment_id )->comment_approved );
    8181
    8282        $this->myxmlrpcserver->wp_editComment(
     
    9292        );
    9393
    94         $this->assertEquals( 'trash', get_comment( $comment_id )->comment_approved );
     94        $this->assertSame( 'trash', get_comment( $comment_id )->comment_approved );
    9595    }
    9696}
Note: See TracChangeset for help on using the changeset viewer.