Make WordPress Core


Ignore:
Timestamp:
09/02/2020 12:35:36 AM (4 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/error-protection/recovery-mode-cookie-service.php

    r46586 r48937  
    1515        $error = $service->validate_cookie( 'gibbersih' );
    1616        $this->assertWPError( $error );
    17         $this->assertEquals( 'invalid_format', $error->get_error_code() );
     17        $this->assertSame( 'invalid_format', $error->get_error_code() );
    1818
    1919        $error = $service->validate_cookie( base64_encode( 'test|data|format' ) );
    2020        $this->assertWPError( $error );
    21         $this->assertEquals( 'invalid_format', $error->get_error_code() );
     21        $this->assertSame( 'invalid_format', $error->get_error_code() );
    2222
    2323        $error = $service->validate_cookie( base64_encode( 'test|data|format|to|long' ) );
    2424        $this->assertWPError( $error );
    25         $this->assertEquals( 'invalid_format', $error->get_error_code() );
     25        $this->assertSame( 'invalid_format', $error->get_error_code() );
    2626    }
    2727
     
    4040        $error = $service->validate_cookie( $cookie );
    4141        $this->assertWPError( $error );
    42         $this->assertEquals( 'expired', $error->get_error_code() );
     42        $this->assertSame( 'expired', $error->get_error_code() );
    4343    }
    4444
     
    5656        $error = $service->validate_cookie( $cookie );
    5757        $this->assertWPError( $error );
    58         $this->assertEquals( 'signature_mismatch', $error->get_error_code() );
     58        $this->assertSame( 'signature_mismatch', $error->get_error_code() );
    5959    }
    6060
     
    7373        $error = $service->validate_cookie( $cookie );
    7474        $this->assertWPError( $error );
    75         $this->assertEquals( 'invalid_created_at', $error->get_error_code() );
     75        $this->assertSame( 'invalid_created_at', $error->get_error_code() );
    7676    }
    7777
Note: See TracChangeset for help on using the changeset viewer.