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/error-protection/recovery-mode-key-service.php

    r47122 r48937  
    2525
    2626        $this->assertWPError( $error );
    27         $this->assertEquals( 'token_not_found', $error->get_error_code() );
     27        $this->assertSame( 'token_not_found', $error->get_error_code() );
    2828    }
    2929
     
    3838
    3939        $this->assertWPError( $error );
    40         $this->assertEquals( 'token_not_found', $error->get_error_code() );
     40        $this->assertSame( 'token_not_found', $error->get_error_code() );
    4141    }
    4242
     
    5151
    5252        $this->assertWPError( $error );
    53         $this->assertEquals( 'invalid_recovery_key_format', $error->get_error_code() );
     53        $this->assertSame( 'invalid_recovery_key_format', $error->get_error_code() );
    5454    }
    5555
     
    6767
    6868        $this->assertWPError( $error );
    69         $this->assertEquals( 'invalid_recovery_key_format', $error->get_error_code() );
     69        $this->assertSame( 'invalid_recovery_key_format', $error->get_error_code() );
    7070    }
    7171
     
    8080
    8181        $this->assertWPError( $error );
    82         $this->assertEquals( 'hash_mismatch', $error->get_error_code() );
     82        $this->assertSame( 'hash_mismatch', $error->get_error_code() );
    8383    }
    8484
     
    9393
    9494        $this->assertWPError( $error );
    95         $this->assertEquals( 'hash_mismatch', $error->get_error_code() );
     95        $this->assertSame( 'hash_mismatch', $error->get_error_code() );
    9696    }
    9797
     
    111111
    112112        $this->assertWPError( $error );
    113         $this->assertEquals( 'key_expired', $error->get_error_code() );
     113        $this->assertSame( 'key_expired', $error->get_error_code() );
    114114    }
    115115
     
    138138
    139139        $this->assertWPError( $error );
    140         $this->assertEquals( 'token_not_found', $error->get_error_code() );
     140        $this->assertSame( 'token_not_found', $error->get_error_code() );
    141141    }
    142142
     
    160160
    161161        $this->assertWPError( $error );
    162         $this->assertEquals( 'token_not_found', $error->get_error_code() );
     162        $this->assertSame( 'token_not_found', $error->get_error_code() );
    163163    }
    164164
Note: See TracChangeset for help on using the changeset viewer.