Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (3 years 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/option/networkOption.php

    r46586 r48937  
    3434
    3535        add_network_option( $id, $option, $value );
    36         $this->assertEquals( $value, get_network_option( $id, $option, false ) );
     36        $this->assertSame( $value, get_network_option( $id, $option, false ) );
    3737    }
    3838
     
    4848        add_network_option( $id, $option, $value );
    4949        delete_site_option( $option );
    50         $this->assertEquals( $value, get_network_option( $id, $option, false ) );
     50        $this->assertSame( $value, get_network_option( $id, $option, false ) );
    5151    }
    5252
     
    8989        $value  = rand_str();
    9090
    91         $this->assertEquals( $expected_response, add_network_option( $network_id, $option, $value ) );
     91        $this->assertSame( $expected_response, add_network_option( $network_id, $option, $value ) );
    9292    }
    9393
     
    101101        $option = rand_str();
    102102
    103         $this->assertEquals( $expected_response, get_network_option( $network_id, $option, true ) );
     103        $this->assertSame( $expected_response, get_network_option( $network_id, $option, true ) );
    104104    }
    105105
     
    204204
    205205        // Check that no new database queries were performed.
    206         $this->assertEquals( $num_queries_pre_update, get_num_queries() );
     206        $this->assertSame( $num_queries_pre_update, get_num_queries() );
    207207    }
    208208}
Note: See TracChangeset for help on using the changeset viewer.