Changeset 51908 for trunk/tests/phpunit/tests/rest-api/rest-controller.php
- Timestamp:
- 10/15/2021 02:03:38 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-controller.php
r51568 r51908 24 24 array( 25 25 'args' => array( 26 'someinteger' => array(26 'someinteger' => array( 27 27 'type' => 'integer', 28 28 ), 29 'someboolean' => array(29 'someboolean' => array( 30 30 'type' => 'boolean', 31 31 ), 32 'somestring' => array(32 'somestring' => array( 33 33 'type' => 'string', 34 34 ), 35 'somehex' => array(35 'somehex' => array( 36 36 'type' => 'string', 37 37 'format' => 'hex-color', 38 38 ), 39 'someenum' => array(39 'someenum' => array( 40 40 'type' => 'string', 41 41 'enum' => array( 'a' ), 42 42 ), 43 'somedate' => array(43 'somedate' => array( 44 44 'type' => 'string', 45 45 'format' => 'date-time', 46 46 ), 47 'someemail' => array(47 'someemail' => array( 48 48 'type' => 'string', 49 49 'format' => 'email', 50 50 ), 51 'someuuid' => array(51 'someuuid' => array( 52 52 'type' => 'string', 53 53 'format' => 'uuid', 54 ), 55 'sometextfield' => array( 56 'type' => 'string', 57 'format' => 'text-field', 58 ), 59 'sometextareafield' => array( 60 'type' => 'string', 61 'format' => 'textarea-field', 54 62 ), 55 63 ), … … 217 225 'rest_invalid_uuid', 218 226 rest_validate_request_arg( '123e4567-e89b-12d3-a456-426655440000X', $this->request, 'someuuid' ) 227 ); 228 } 229 230 /** 231 * @ticket 49960 232 */ 233 public function test_validate_schema_format_text_field() { 234 $this->assertTrue( 235 rest_validate_request_arg( 'Hello World', $this->request, 'sometextfield' ) 236 ); 237 238 $this->assertErrorResponse( 239 'rest_invalid_type', 240 rest_validate_request_arg( false, $this->request, 'sometextfield' ) 241 ); 242 243 $this->assertSame( 244 'Hello World', 245 rest_sanitize_request_arg( 'Hello World', $this->request, 'sometextfield' ) 246 ); 247 $this->assertSame( 248 'Hello World', 249 rest_sanitize_request_arg( '<p>Hello World</p>', $this->request, 'sometextfield' ) 250 ); 251 } 252 253 /** 254 * @ticket 49960 255 */ 256 public function test_validate_schema_format_textarea_field() { 257 $this->assertTrue( 258 rest_validate_request_arg( "Hello\nWorld", $this->request, 'sometextareafield' ) 259 ); 260 261 $this->assertErrorResponse( 262 'rest_invalid_type', 263 rest_validate_request_arg( false, $this->request, 'sometextareafield' ) 264 ); 265 266 $this->assertSame( 267 "Hello\nWorld", 268 rest_sanitize_request_arg( "Hello\nWorld", $this->request, 'sometextareafield' ) 269 ); 270 $this->assertSame( 271 "Hello\nWorld", 272 rest_sanitize_request_arg( "<p>Hello\nWorld</p>", $this->request, 'sometextareafield' ) 219 273 ); 220 274 } … … 235 289 $this->assertArrayHasKey( 'somehex', $args ); 236 290 $this->assertArrayHasKey( 'someuuid', $args ); 291 $this->assertArrayHasKey( 'sometextfield', $args ); 292 $this->assertArrayHasKey( 'sometextareafield', $args ); 237 293 $this->assertArrayHasKey( 'someenum', $args ); 238 294 $this->assertArrayHasKey( 'someargoptions', $args ); … … 324 380 'somehex', 325 381 'someuuid', 382 'sometextfield', 383 'sometextareafield', 326 384 'someenum', 327 385 'someargoptions', … … 357 415 'somehex', 358 416 'someuuid', 417 'sometextfield', 418 'sometextareafield', 359 419 'someenum', 360 420 'someargoptions',
Note: See TracChangeset
for help on using the changeset viewer.