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/post/types.php

    r48858 r48937  
    3131        $pobj = get_post_type_object( 'foo' );
    3232        $this->assertInstanceOf( 'WP_Post_Type', $pobj );
    33         $this->assertEquals( 'foo', $pobj->name );
     33        $this->assertSame( 'foo', $pobj->name );
    3434
    3535        // Test some defaults.
    3636        $this->assertFalse( is_post_type_hierarchical( 'foo' ) );
    37         $this->assertEquals( array(), get_object_taxonomies( 'foo' ) );
     37        $this->assertSame( array(), get_object_taxonomies( 'foo' ) );
    3838
    3939        _unregister_post_type( 'foo' );
     
    169169        register_post_type( 'bar' );
    170170        register_taxonomy_for_object_type( 'post_tag', 'bar' );
    171         $this->assertEquals( array( 'post_tag' ), get_object_taxonomies( 'bar' ) );
     171        $this->assertSame( array( 'post_tag' ), get_object_taxonomies( 'bar' ) );
    172172        register_taxonomy_for_object_type( 'category', 'bar' );
    173         $this->assertEquals( array( 'category', 'post_tag' ), get_object_taxonomies( 'bar' ) );
     173        $this->assertSame( array( 'category', 'post_tag' ), get_object_taxonomies( 'bar' ) );
    174174
    175175        $this->assertTrue( is_object_in_taxonomy( 'bar', 'post_tag' ) );
     
    268268     */
    269269    public function test_get_post_type_object_includes_menu_icon_for_builtin_post_types() {
    270         $this->assertEquals( 'dashicons-admin-post', get_post_type_object( 'post' )->menu_icon );
    271         $this->assertEquals( 'dashicons-admin-page', get_post_type_object( 'page' )->menu_icon );
    272         $this->assertEquals( 'dashicons-admin-media', get_post_type_object( 'attachment' )->menu_icon );
     270        $this->assertSame( 'dashicons-admin-post', get_post_type_object( 'post' )->menu_icon );
     271        $this->assertSame( 'dashicons-admin-page', get_post_type_object( 'page' )->menu_icon );
     272        $this->assertSame( 'dashicons-admin-media', get_post_type_object( 'attachment' )->menu_icon );
    273273    }
    274274
Note: See TracChangeset for help on using the changeset viewer.