Make WordPress Core


Ignore:
Timestamp:
03/12/2020 02:40:29 AM (7 years ago)
Author:
TimothyBlynJacobs
Message:

REST API: Introduce "hex-color" JSON Schema format.

Props spacedmonkey, chrisvanpatten.
Fixes #49270.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-controller.php

    r47328 r47450  
    2828                                                'type' => 'string',
    2929                                        ),
     30                                        'somehex'     => array(
     31                                                'type'   => 'string',
     32                                                'format' => 'hex-color',
     33                                        ),
    3034                                        'someenum'    => array(
    3135                                                'type' => 'string',
    … …  
    164168                        'rest_invalid_email',
    165169                        rest_validate_request_arg( 'd', $this->request, 'someemail' )
     170                );
     171        }
     172
     173        /**
     174         * @ticket 49270
     175         */
     176        public function test_validate_schema_format_hex_color() {
     177
     178                $this->assertTrue(
     179                        rest_validate_request_arg( '#000000', $this->request, 'somehex' )
     180                );
     181
     182                $this->assertErrorResponse(
     183                        'rest_invalid_hex_color',
     184                        rest_validate_request_arg( 'wibble', $this->request, 'somehex' )
    166185                );
    167186        }
    … …  
    219238                                'somedate',
    220239                                'someemail',
     240                                'somehex',
    221241                                'someenum',
    222242                                'someargoptions',
    … …  
    248268                                        'somedate',
    249269                                        'someemail',
     270                                        'somehex',
    250271                                        'someenum',
    251272                                        'someargoptions',
Note: See TracChangeset for help on using the changeset viewer.