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/getCommentAuthorUrlLink.php

    r46586 r48937  
    2828        $url_link = get_comment_author_url_link();
    2929
    30         $this->assertEquals( "<a href='' rel='external'></a>", $url_link );
     30        $this->assertSame( "<a href='' rel='external'></a>", $url_link );
    3131    }
    3232
     
    3737        $url_link = get_comment_author_url_link();
    3838        $link     = $this->parseCommentAuthorUrl( $comment );
    39         $this->assertEquals( $link, $url_link );
     39        $this->assertSame( $link, $url_link );
    4040    }
    4141
     
    4545        $url_link = get_comment_author_url_link( '', '', '', $comment );
    4646        $link     = $this->parseCommentAuthorUrl( $comment );
    47         $this->assertEquals( $link, $url_link );
     47        $this->assertSame( $link, $url_link );
    4848    }
    4949
     
    5353        $url_link = get_comment_author_url_link( 'Burrito', '', '', $comment );
    5454        $link     = $this->parseCommentAuthorUrl( $comment, 'Burrito' );
    55         $this->assertEquals( $link, $url_link );
     55        $this->assertSame( $link, $url_link );
    5656    }
    5757
     
    6161        $url_link = get_comment_author_url_link( 'Burrito', 'I would love a ', '', $comment );
    6262        $link     = 'I would love a ' . $this->parseCommentAuthorUrl( $comment, 'Burrito' );
    63         $this->assertEquals( $link, $url_link );
     63        $this->assertSame( $link, $url_link );
    6464    }
    6565
     
    6969        $url_link = get_comment_author_url_link( 'Burrito', '', ' is my favorite word.', $comment );
    7070        $link     = $this->parseCommentAuthorUrl( $comment, 'Burrito' ) . ' is my favorite word.';
    71         $this->assertEquals( $link, $url_link );
     71        $this->assertSame( $link, $url_link );
    7272    }
    7373
     
    7777        $url_link = get_comment_author_url_link( 'Burrito', 'I would love a ', ' right now.', $comment );
    7878        $link     = 'I would love a ' . $this->parseCommentAuthorUrl( $comment, 'Burrito' ) . ' right now.';
    79         $this->assertEquals( $link, $url_link );
     79        $this->assertSame( $link, $url_link );
    8080    }
    8181}
Note: See TracChangeset for help on using the changeset viewer.