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/multisite/updateBlogDetails.php

    r46586 r48937  
    4040            $blog = get_site( $blog_id );
    4141
    42             $this->assertEquals( 'example.com', $blog->domain );
    43             $this->assertEquals( '/my_path/', $blog->path );
    44             $this->assertEquals( '0', $blog->spam );
     42            $this->assertSame( 'example.com', $blog->domain );
     43            $this->assertSame( '/my_path/', $blog->path );
     44            $this->assertSame( '0', $blog->spam );
    4545        }
    4646
     
    7272            $blog = get_site( $blog_id );
    7373
    74             $this->assertEquals( $flag_value, $blog->{$flag} );
     74            $this->assertSame( $flag_value, $blog->{$flag} );
    7575
    7676            // The hook attached to this flag should have fired once during update_blog_details().
    77             $this->assertEquals( 1, $test_action_counter );
     77            $this->assertSame( 1, $test_action_counter );
    7878
    7979            // Update the site to the exact same flag value for this flag.
     
    8181
    8282            // The hook attached to this flag should not have fired again.
    83             $this->assertEquals( 1, $test_action_counter );
     83            $this->assertSame( 1, $test_action_counter );
    8484
    8585            remove_action( $hook, array( $this, '_action_counter_cb' ), 10 );
     
    117117            $site = get_site( 1 );
    118118
    119             $this->assertEquals( $expected, $site->path );
     119            $this->assertSame( $expected, $site->path );
    120120        }
    121121
Note: See TracChangeset for help on using the changeset viewer.