- Timestamp:
- 06/07/2020 10:40:16 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-schema-validation.php
r47810 r47923 767 767 $this->assertWPError( rest_validate_value_from_schema( 'ââ', $schema ) ); 768 768 } 769 770 /** 771 * @ticket 48821 772 */ 773 public function test_array_min_items() { 774 $schema = array( 775 'type' => 'array', 776 'minItems' => 1, 777 'items' => array( 778 'type' => 'number', 779 ), 780 ); 781 782 $this->assertTrue( rest_validate_value_from_schema( array( 1, 2 ), $schema ) ); 783 $this->assertTrue( rest_validate_value_from_schema( array( 1 ), $schema ) ); 784 $this->assertWPError( rest_validate_value_from_schema( array(), $schema ) ); 785 $this->assertWPError( rest_validate_value_from_schema( '', $schema ) ); 786 } 787 788 /** 789 * @ticket 48821 790 */ 791 public function test_array_max_items() { 792 $schema = array( 793 'type' => 'array', 794 'maxItems' => 2, 795 'items' => array( 796 'type' => 'number', 797 ), 798 ); 799 800 $this->assertTrue( rest_validate_value_from_schema( array( 1 ), $schema ) ); 801 $this->assertTrue( rest_validate_value_from_schema( array( 1, 2 ), $schema ) ); 802 $this->assertWPError( rest_validate_value_from_schema( array( 1, 2, 3 ), $schema ) ); 803 $this->assertWPError( rest_validate_value_from_schema( 'foobar', $schema ) ); 804 } 769 805 }
Note: See TracChangeset
for help on using the changeset viewer.