- Timestamp:
- 07/04/2020 07:51:10 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-schema-validation.php
r48190 r48300 138 138 } 139 139 140 /** 141 * @ticket 50189 142 */ 143 public function test_format_validation_is_skipped_if_non_string_type() { 144 $schema = array( 145 'type' => 'array', 146 'items' => array( 147 'type' => 'string', 148 ), 149 'format' => 'email', 150 ); 151 $this->assertTrue( rest_validate_value_from_schema( 'email@example.com', $schema ) ); 152 $this->assertTrue( rest_validate_value_from_schema( 'email', $schema ) ); 153 } 154 155 /** 156 * @ticket 50189 157 */ 158 public function test_format_validation_is_applied_if_missing_type() { 159 $this->expectException( 'PHPUnit_Framework_Error_Notice' ); // For the undefined index. 160 $this->setExpectedIncorrectUsage( 'rest_validate_value_from_schema' ); 161 162 $schema = array( 'format' => 'email' ); 163 $this->assertTrue( rest_validate_value_from_schema( 'email@example.com', $schema ) ); 164 $this->assertWPError( rest_validate_value_from_schema( 'email', $schema ) ); 165 } 166 167 /** 168 * @ticket 50189 169 */ 170 public function test_format_validation_is_applied_if_unknown_type() { 171 $this->setExpectedIncorrectUsage( 'rest_validate_value_from_schema' ); 172 173 $schema = array( 174 'format' => 'email', 175 'type' => 'str', 176 ); 177 $this->assertTrue( rest_validate_value_from_schema( 'email@example.com', $schema ) ); 178 $this->assertWPError( rest_validate_value_from_schema( 'email', $schema ) ); 179 } 180 140 181 public function test_type_array() { 141 182 $schema = array( … … 323 364 324 365 public function test_type_unknown() { 366 $this->setExpectedIncorrectUsage( 'rest_validate_value_from_schema' ); 367 325 368 $schema = array( 326 369 'type' => 'lalala',
Note: See TracChangeset
for help on using the changeset viewer.