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/l10n/loadScriptTextdomain.php

    r46586 r48937  
    3333
    3434        wp_enqueue_script( 'test-example-root', '/wp-includes/js/script.js', array(), null );
    35         $this->assertEquals( $json_translations, load_script_textdomain( 'test-example-root', 'default', DIR_TESTDATA . '/languages' ) );
     35        $this->assertSame( $json_translations, load_script_textdomain( 'test-example-root', 'default', DIR_TESTDATA . '/languages' ) );
    3636
    3737        // Assets on a CDN.
    3838        add_filter( 'load_script_textdomain_relative_path', array( $this, 'relative_path_from_cdn' ), 10, 2 );
    3939        wp_enqueue_script( 'test-example-cdn', 'https://my-cdn.com/wordpress/wp-includes/js/script.js', array(), null );
    40         $this->assertEquals( $json_translations, load_script_textdomain( 'test-example-cdn', 'default', DIR_TESTDATA . '/languages' ) );
     40        $this->assertSame( $json_translations, load_script_textdomain( 'test-example-cdn', 'default', DIR_TESTDATA . '/languages' ) );
    4141        remove_filter( 'load_script_textdomain_relative_path', array( $this, 'relative_path_from_cdn' ) );
    4242
     
    4444        add_filter( 'site_url', array( $this, 'site_url_subdirectory' ) );
    4545        wp_enqueue_script( 'test-example-subdir', '/wp/wp-includes/js/script.js', array(), null );
    46         $this->assertEquals( $json_translations, load_script_textdomain( 'test-example-subdir', 'default', DIR_TESTDATA . '/languages' ) );
     46        $this->assertSame( $json_translations, load_script_textdomain( 'test-example-subdir', 'default', DIR_TESTDATA . '/languages' ) );
    4747        remove_filter( 'site_url', array( $this, 'site_url_subdirectory' ) );
    4848    }
     
    5656        add_filter( 'plugins_url', array( $this, 'plugins_url_custom_domain' ) );
    5757        wp_enqueue_script( 'plugin-example-1', 'https://plugins.example.com/my-plugin/js/script.js', array(), null );
    58         $this->assertEquals( $json_translations, load_script_textdomain( 'plugin-example-1', 'internationalized-plugin', DIR_TESTDATA . '/languages' ) );
     58        $this->assertSame( $json_translations, load_script_textdomain( 'plugin-example-1', 'internationalized-plugin', DIR_TESTDATA . '/languages' ) );
    5959        remove_filter( 'plugins_url', array( $this, 'plugins_url_custom_domain' ) );
    6060    }
     
    6868        add_filter( 'content_url', array( $this, 'content_url_custom_domain_with_no_path' ) );
    6969        wp_enqueue_script( 'plugin-example-2', 'https://content.example.com/plugins/my-plugin/js/script.js', array(), null );
    70         $this->assertEquals( $json_translations, load_script_textdomain( 'plugin-example-2', 'internationalized-plugin', DIR_TESTDATA . '/languages' ) );
     70        $this->assertSame( $json_translations, load_script_textdomain( 'plugin-example-2', 'internationalized-plugin', DIR_TESTDATA . '/languages' ) );
    7171        remove_filter( 'content_url', array( $this, 'content_url_custom_domain_with_no_path' ) );
    7272    }
Note: See TracChangeset for help on using the changeset viewer.