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

    r46586 r48937  
    1212        $content  = '<p>This is some cool <a href="/">Code</a></p>';
    1313        $expected = '<p>This is some cool <a href=\"/\" rel=\"nofollow ugc\">Code</a></p>';
    14         $this->assertEquals( $expected, wp_rel_ugc( $content ) );
     14        $this->assertSame( $expected, wp_rel_ugc( $content ) );
    1515    }
    1616
     
    2121        $content  = '<p>This is some cool <a href="/" rel="weird">Code</a></p>';
    2222        $expected = '<p>This is some cool <a href=\"/\" rel=\"weird nofollow ugc\">Code</a></p>';
    23         $this->assertEquals( $expected, wp_rel_ugc( $content ) );
     23        $this->assertSame( $expected, wp_rel_ugc( $content ) );
    2424    }
    2525
     
    2929     */
    3030    public function test_wp_rel_ugc( $input, $output ) {
    31         return $this->assertEquals( wp_slash( $output ), wp_rel_ugc( $input ) );
     31        return $this->assertSame( wp_slash( $output ), wp_rel_ugc( $input ) );
    3232    }
    3333
     
    7979        $content  = '<p>This is some cool <a href="demo.com" download rel="hola">Code</a></p>';
    8080        $expected = '<p>This is some cool <a href=\"demo.com\" download rel=\"hola nofollow ugc\">Code</a></p>';
    81         $this->assertEquals( $expected, wp_rel_ugc( $content ) );
     81        $this->assertSame( $expected, wp_rel_ugc( $content ) );
    8282    }
    8383}
Note: See TracChangeset for help on using the changeset viewer.