Skip to content

Commit 0089ba1

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@60067 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 327d76b commit 0089ba1

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

tests/phpunit/tests/rest-api/rest-schema-sanitization.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public function test_type_number() {
1313
$schema = array(
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

2323
public function test_type_integer() {

0 commit comments

Comments
 (0)