WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/12/2020 02:40:29 AM (19 months 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-schema-sanitization.php

    r47362 r47450  
    7878    }
    7979
     80    /**
     81     * @ticket 49270
     82     */
     83    public function test_format_hex_color() {
     84        $schema = array(
     85            'type'   => 'string',
     86            'format' => 'hex-color',
     87        );
     88        $this->assertEquals( '#000000', rest_sanitize_value_from_schema( '#000000', $schema ) );
     89        $this->assertEquals( '#FFF', rest_sanitize_value_from_schema( '#FFF', $schema ) );
     90        $this->assertEquals( '', rest_sanitize_value_from_schema( 'WordPress', $schema ) );
     91    }
     92
    8093    public function test_type_array() {
    8194        $schema = array(
Note: See TracChangeset for help on using the changeset viewer.