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/formatting/HtmlExcerpt.php

    r46586 r48937  
    66class Tests_Formatting_HtmlExcerpt extends WP_UnitTestCase {
    77    function test_simple() {
    8         $this->assertEquals( 'Baba', wp_html_excerpt( 'Baba told me not to come', 4 ) );
     8        $this->assertSame( 'Baba', wp_html_excerpt( 'Baba told me not to come', 4 ) );
    99    }
    1010    function test_html() {
    11         $this->assertEquals( 'Baba', wp_html_excerpt( "<a href='http://baba.net/'>Baba</a> told me not to come", 4 ) );
     11        $this->assertSame( 'Baba', wp_html_excerpt( "<a href='http://baba.net/'>Baba</a> told me not to come", 4 ) );
    1212    }
    1313    function test_entities() {
    14         $this->assertEquals( 'Baba', wp_html_excerpt( 'Baba &amp; Dyado', 8 ) );
    15         $this->assertEquals( 'Baba', wp_html_excerpt( 'Baba &#038; Dyado', 8 ) );
    16         $this->assertEquals( 'Baba &amp; D', wp_html_excerpt( 'Baba &amp; Dyado', 12 ) );
    17         $this->assertEquals( 'Baba &amp; Dyado', wp_html_excerpt( 'Baba &amp; Dyado', 100 ) );
     14        $this->assertSame( 'Baba', wp_html_excerpt( 'Baba &amp; Dyado', 8 ) );
     15        $this->assertSame( 'Baba', wp_html_excerpt( 'Baba &#038; Dyado', 8 ) );
     16        $this->assertSame( 'Baba &amp; D', wp_html_excerpt( 'Baba &amp; Dyado', 12 ) );
     17        $this->assertSame( 'Baba &amp; Dyado', wp_html_excerpt( 'Baba &amp; Dyado', 100 ) );
    1818    }
    1919}
Note: See TracChangeset for help on using the changeset viewer.