Make WordPress Core


Ignore:
Timestamp:
07/07/2020 03:20:34 AM (4 years ago)
Author:
TimothyBlynJacobs
Message:

REST API: Add support for the uniqueItems keyword.

Props sorenbronsted.
Fixes #48821.

File:
1 edited

Legend:

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

    r48306 r48357  
    465465        $this->assertNull( rest_sanitize_value_from_schema( array( 'Hello!' ), $schema ) );
    466466    }
     467
     468    /**
     469     * @ticket 48821
     470     */
     471    public function test_unique_items_after_sanitization() {
     472        $schema = array(
     473            'type'        => 'array',
     474            'uniqueItems' => true,
     475            'items'       => array(
     476                'type'   => 'string',
     477                'format' => 'uri',
     478            ),
     479        );
     480
     481        $data = array(
     482            'https://example.org/hello%20world',
     483            'https://example.org/hello world',
     484        );
     485
     486        $this->assertTrue( rest_validate_value_from_schema( $data, $schema ) );
     487        $this->assertWPError( rest_sanitize_value_from_schema( $data, $schema ) );
     488    }
    467489}
Note: See TracChangeset for help on using the changeset viewer.