- Timestamp:
- 05/16/2020 07:01:49 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-schema-validation.php
r47809 r47810 728 728 ); 729 729 } 730 731 /** 732 * @ticket 44949 733 */ 734 public function test_string_pattern() { 735 $schema = array( 736 'type' => 'string', 737 'pattern' => '^a*$', 738 ); 739 740 $this->assertTrue( rest_validate_value_from_schema( 'a', $schema ) ); 741 $this->assertWPError( rest_validate_value_from_schema( 'b', $schema ) ); 742 } 743 744 /** 745 * @ticket 44949 746 */ 747 public function test_string_pattern_with_escaped_delimiter() { 748 $schema = array( 749 'type' => 'string', 750 'pattern' => '#[0-9]+', 751 ); 752 753 $this->assertTrue( rest_validate_value_from_schema( '#123', $schema ) ); 754 $this->assertWPError( rest_validate_value_from_schema( '#abc', $schema ) ); 755 } 756 757 /** 758 * @ticket 44949 759 */ 760 public function test_string_pattern_with_utf8() { 761 $schema = array( 762 'type' => 'string', 763 'pattern' => '^â{1}$', 764 ); 765 766 $this->assertTrue( rest_validate_value_from_schema( 'â', $schema ) ); 767 $this->assertWPError( rest_validate_value_from_schema( 'ââ', $schema ) ); 768 } 730 769 }
Note: See TracChangeset
for help on using the changeset viewer.