Make WordPress Core

Changeset 60067


Ignore:
Timestamp:
03/21/2025 11:46:14 PM (8 months ago)
Author:
SergeyBiryukov
Message:

Tests: Use assertSame() in REST API schema sanitization 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.

Follow-up to [39061], [48937].

See #62278.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-schema-sanitization.php

    r55457 r60067  
    1414            'type' => 'number',
    1515        );
    16         $this->assertEquals( 1, rest_sanitize_value_from_schema( 1, $schema ) );
     16        $this->assertSame( 1.0, rest_sanitize_value_from_schema( 1, $schema ) );
    1717        $this->assertSame( 1.10, rest_sanitize_value_from_schema( '1.10', $schema ) );
    18         $this->assertEquals( 1, rest_sanitize_value_from_schema( '1abc', $schema ) );
    19         $this->assertEquals( 0, rest_sanitize_value_from_schema( 'abc', $schema ) );
    20         $this->assertEquals( 0, rest_sanitize_value_from_schema( array(), $schema ) );
     18        $this->assertSame( 1.0, rest_sanitize_value_from_schema( '1abc', $schema ) );
     19        $this->assertSame( 0.0, rest_sanitize_value_from_schema( 'abc', $schema ) );
     20        $this->assertSame( 0.0, rest_sanitize_value_from_schema( array(), $schema ) );
    2121    }
    2222
Note: See TracChangeset for help on using the changeset viewer.