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/comment/getCommentAuthorEmailLink.php

    r46586 r48937  
    3434        $expected = '<a href="mailto:foo@example.org">foo@example.org</a>';
    3535
    36         $this->assertEquals( $expected, get_comment_author_email_link() );
     36        $this->assertSame( $expected, get_comment_author_email_link() );
    3737    }
    3838
     
    5454        $expected = sprintf( '%1$s<a href="mailto:%2$s">%3$s</a>%4$s', $before, $email, $linktext, $after );
    5555
    56         $this->assertEquals( $expected, get_comment_author_email_link( $linktext, $before, $after, $comment ) );
     56        $this->assertSame( $expected, get_comment_author_email_link( $linktext, $before, $after, $comment ) );
    5757    }
    5858
     
    6464        $expected = sprintf( '%1$s<a href="mailto:foo@example.org">%2$s</a>%3$s', $before, $linktext, $after );
    6565
    66         $this->assertEquals( $expected, get_comment_author_email_link( $linktext, $before, $after ) );
     66        $this->assertSame( $expected, get_comment_author_email_link( $linktext, $before, $after ) );
    6767    }
    6868
     
    7070        $expected = sprintf( '<a href="mailto:foo@example.org">%1$s</a>', $linktext = 'linktext' );
    7171
    72         $this->assertEquals( $expected, get_comment_author_email_link( $linktext ) );
     72        $this->assertSame( $expected, get_comment_author_email_link( $linktext ) );
    7373    }
    7474
     
    7676        $expected = sprintf( '%1$s<a href="mailto:foo@example.org">foo@example.org</a>', $before = 'before' );
    7777
    78         $this->assertEquals( $expected, get_comment_author_email_link( '', $before ) );
     78        $this->assertSame( $expected, get_comment_author_email_link( '', $before ) );
    7979    }
    8080
     
    8282        $expected = sprintf( '<a href="mailto:foo@example.org">foo@example.org</a>%1$s', $after = 'after' );
    8383
    84         $this->assertEquals( $expected, get_comment_author_email_link( '', '', $after ) );
     84        $this->assertSame( $expected, get_comment_author_email_link( '', '', $after ) );
    8585    }
    8686
     
    9797        $expected = sprintf( '<a href="mailto:%1$s">%2$s</a>', $email, $email );
    9898
    99         $this->assertEquals( $expected, get_comment_author_email_link( '', '', '', $comment ) );
     99        $this->assertSame( $expected, get_comment_author_email_link( '', '', '', $comment ) );
    100100    }
    101101}
Note: See TracChangeset for help on using the changeset viewer.