Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (17 months 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/general/resourceHints.php

    r46586 r48937  
    5151        remove_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_domains' ) );
    5252
    53         $this->assertEquals( $expected, $actual );
     53        $this->assertSame( $expected, $actual );
    5454    }
    5555
     
    8383        remove_filter( 'wp_resource_hints', array( $this, '_add_preconnect_domains' ) );
    8484
    85         $this->assertEquals( $expected, $actual );
     85        $this->assertSame( $expected, $actual );
    8686    }
    8787
     
    110110        remove_filter( 'wp_resource_hints', array( $this, '_add_prerender_urls' ) );
    111111
    112         $this->assertEquals( $expected, $actual );
     112        $this->assertSame( $expected, $actual );
    113113    }
    114114
     
    134134        remove_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_long_urls' ) );
    135135
    136         $this->assertEquals( $expected, $actual );
     136        $this->assertSame( $expected, $actual );
    137137    }
    138138
     
    160160        wp_dequeue_style( 'googlefonts' );
    161161
    162         $this->assertEquals( $expected, $actual );
     162        $this->assertSame( $expected, $actual );
    163163
    164164    }
     
    179179        wp_dequeue_style( 'googlefonts' );
    180180
    181         $this->assertEquals( $expected, $actual );
     181        $this->assertSame( $expected, $actual );
    182182    }
    183183
     
    192192        wp_deregister_script( 'jquery-elsewhere' );
    193193
    194         $this->assertEquals( $expected, $actual );
     194        $this->assertSame( $expected, $actual );
    195195        $this->assertNotContains( $unexpected, $actual );
    196196    }
     
    206206
    207207        $actual = get_echo( 'wp_resource_hints' );
    208         $this->assertEquals( $expected, $actual );
     208        $this->assertSame( $expected, $actual );
    209209    }
    210210
     
    219219        $actual = get_echo( 'wp_resource_hints' );
    220220        remove_filter( 'wp_resource_hints', array( $this, '_add_malformed_url_errant_colon' ) );
    221         $this->assertEquals( $expected, $actual );
     221        $this->assertSame( $expected, $actual );
    222222
    223223        // Unsupported Scheme.
     
    225225        $actual = get_echo( 'wp_resource_hints' );
    226226        remove_filter( 'wp_resource_hints', array( $this, '_add_malformed_url_unsupported_scheme' ) );
    227         $this->assertEquals( $expected, $actual );
     227        $this->assertSame( $expected, $actual );
    228228    }
    229229
     
    260260        remove_filter( 'wp_resource_hints', array( $this, '_add_url_with_attributes' ) );
    261261
    262         $this->assertEquals( $expected, $actual );
     262        $this->assertSame( $expected, $actual );
    263263    }
    264264
Note: See TracChangeset for help on using the changeset viewer.