- Timestamp:
- 07/05/2020 12:13:37 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-schema-sanitization.php
r48300 r48306 342 342 $this->assertNull( rest_sanitize_value_from_schema( null, $schema ) ); 343 343 $this->assertEquals( '2019-09-19T18:00:00', rest_sanitize_value_from_schema( '2019-09-19T18:00:00', $schema ) ); 344 $this->assert Null(rest_sanitize_value_from_schema( 'lalala', $schema ) );344 $this->assertEquals( 'lalala', rest_sanitize_value_from_schema( 'lalala', $schema ) ); 345 345 } 346 346 … … 395 395 $this->assertEquals( 'My Value', rest_sanitize_value_from_schema( 'My Value', $schema ) ); 396 396 $this->assertEquals( array( 'raw' => 'My Value' ), rest_sanitize_value_from_schema( array( 'raw' => 'My Value' ), $schema ) ); 397 $this->assert Null(rest_sanitize_value_from_schema( array( 'raw' => 1 ), $schema ) );397 $this->assertEquals( array( 'raw' => '1' ), rest_sanitize_value_from_schema( array( 'raw' => 1 ), $schema ) ); 398 398 } 399 399 … … 424 424 $this->assertEquals( array( 'raw' => false ), rest_sanitize_value_from_schema( array( 'raw' => 0 ), $schema ) ); 425 425 426 $this->assertNull( rest_sanitize_value_from_schema( array( 'raw' => 'something non boolean' ), $schema ) ); 426 $this->assertEquals( array( 'raw' => true ), rest_sanitize_value_from_schema( array( 'raw' => 'something non boolean' ), $schema ) ); 427 } 428 429 /** 430 * @ticket 50300 431 */ 432 public function test_multi_type_with_no_known_types() { 433 $this->setExpectedIncorrectUsage( 'rest_handle_multi_type_schema' ); 434 $this->setExpectedIncorrectUsage( 'rest_sanitize_value_from_schema' ); 435 436 $schema = array( 437 'type' => array( 'invalid', 'type' ), 438 ); 439 440 $this->assertEquals( 'My Value', rest_sanitize_value_from_schema( 'My Value', $schema ) ); 441 } 442 443 /** 444 * @ticket 50300 445 */ 446 public function test_multi_type_with_some_unknown_types() { 447 $this->setExpectedIncorrectUsage( 'rest_handle_multi_type_schema' ); 448 $this->setExpectedIncorrectUsage( 'rest_sanitize_value_from_schema' ); 449 450 $schema = array( 451 'type' => array( 'object', 'type' ), 452 ); 453 454 $this->assertEquals( 'My Value', rest_sanitize_value_from_schema( 'My Value', $schema ) ); 455 } 456 457 /** 458 * @ticket 50300 459 */ 460 public function test_multi_type_returns_null_if_no_valid_type() { 461 $schema = array( 462 'type' => array( 'number', 'string' ), 463 ); 464 465 $this->assertNull( rest_sanitize_value_from_schema( array( 'Hello!' ), $schema ) ); 427 466 } 428 467 }
Note: See TracChangeset
for help on using the changeset viewer.