WordPress.org

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/dependencies/styles.php

    r47122 r48937  
    6464        $expected .= "<link rel='stylesheet' id='no-deps-null-version-print-media-css'  href='http://example.com' type='text/css' media='print' />\n";
    6565
    66         $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
     66        $this->assertSame( $expected, get_echo( 'wp_print_styles' ) );
    6767
    6868        // No styles left to print.
    69         $this->assertEquals( '', get_echo( 'wp_print_styles' ) );
     69        $this->assertSame( '', get_echo( 'wp_print_styles' ) );
    7070    }
    7171
     
    8484        $expected = "<link rel='stylesheet' id='no-deps-no-version-css'  href='http://example.com?ver=$ver' media='all' />\n";
    8585
    86         $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
     86        $this->assertSame( $expected, get_echo( 'wp_print_styles' ) );
    8787    }
    8888
     
    123123
    124124        // Go!
    125         $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
     125        $this->assertSame( $expected, get_echo( 'wp_print_styles' ) );
    126126
    127127        // No styles left to print.
    128         $this->assertEquals( '', get_echo( 'wp_print_styles' ) );
     128        $this->assertSame( '', get_echo( 'wp_print_styles' ) );
    129129
    130130        // Cleanup.
     
    152152
    153153        // No styles left to print.
    154         $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
     154        $this->assertSame( $expected, get_echo( 'wp_print_styles' ) );
    155155    }
    156156
     
    181181
    182182        wp_print_styles();
    183         $this->assertEquals( $expected, $wp_styles->print_html );
     183        $this->assertSame( $expected, $wp_styles->print_html );
    184184
    185185    }
     
    211211
    212212        // No styles left to print.
    213         $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
     213        $this->assertSame( $expected, get_echo( 'wp_print_styles' ) );
    214214
    215215    }
     
    236236        wp_add_inline_style( 'handle', $style );
    237237
    238         $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
     238        $this->assertSame( $expected, get_echo( 'wp_print_styles' ) );
    239239
    240240    }
     
    251251        wp_enqueue_style( 'handle', 'http://example.com', array(), 1 );
    252252
    253         $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
     253        $this->assertSame( $expected, get_echo( 'wp_print_styles' ) );
    254254
    255255    }
     
    273273        wp_add_inline_style( 'handle', 'a { color: blue; }' );
    274274
    275         $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_styles' ) );
     275        $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_styles' ) );
    276276    }
    277277
     
    305305        wp_add_inline_style( 'handle-three', $style );
    306306
    307         $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
     307        $this->assertSame( $expected, get_echo( 'wp_print_styles' ) );
    308308    }
    309309
Note: See TracChangeset for help on using the changeset viewer.