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/rest-api/rest-schema-validation.php

    r48881 r48937  
    391391        $error = rest_validate_value_from_schema( 'some random string', $schema );
    392392        $this->assertWPError( $error );
    393         $this->assertEquals( 'Invalid date.', $error->get_error_message() );
     393        $this->assertSame( 'Invalid date.', $error->get_error_message() );
    394394    }
    395395
     
    409409        $error = rest_validate_value_from_schema( array( 'raw' => array( 'a list' ) ), $schema );
    410410        $this->assertWPError( $error );
    411         $this->assertEquals( '[raw] is not of type string.', $error->get_error_message() );
     411        $this->assertSame( '[raw] is not of type string.', $error->get_error_message() );
    412412    }
    413413
     
    428428        $error = rest_validate_value_from_schema( 30, $schema, 'param' );
    429429        $this->assertWPError( $error );
    430         $this->assertEquals( 'param must be between 10 (inclusive) and 20 (inclusive)', $error->get_error_message() );
     430        $this->assertSame( 'param must be between 10 (inclusive) and 20 (inclusive)', $error->get_error_message() );
    431431    }
    432432
Note: See TracChangeset for help on using the changeset viewer.