WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/03/2016 01:45:48 AM (5 years ago)
Author:
joehoyle
Message:

REST API: Support querying for multiple post statuses.

Multiple post statuses can be specified by the usual CSV or array-propper format.

Props jnylen0, kadamwhite, websupporter.
Fixes #38420.

File:
1 edited

Legend:

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

    r39061 r39104  
    8787        $this->assertEquals( array( 1, 2, 0 ), rest_sanitize_value_from_schema( '1,2,a', $schema ) );
    8888    }
     89
     90    public function test_type_array_with_enum() {
     91        $schema = array(
     92            'type'  => 'array',
     93            'items' => array(
     94                'enum' => array( 'chicken', 'ribs', 'brisket' ),
     95                'type' => 'string',
     96            ),
     97        );
     98        $this->assertEquals( array( 'ribs', 'brisket' ), rest_sanitize_value_from_schema( array( 'ribs', 'brisket' ), $schema ) );
     99        $this->assertEquals( array( 'coleslaw' ), rest_sanitize_value_from_schema( array( 'coleslaw' ), $schema ) );
     100    }
     101
     102    public function test_type_array_with_enum_as_csv() {
     103        $schema = array(
     104            'type'  => 'array',
     105            'items' => array(
     106                'enum' => array( 'chicken', 'ribs', 'brisket' ),
     107                'type' => 'string',
     108            ),
     109        );
     110        $this->assertEquals( array( 'ribs', 'chicken' ), rest_sanitize_value_from_schema( 'ribs,chicken', $schema ) );
     111        $this->assertEquals( array( 'chicken', 'coleslaw' ), rest_sanitize_value_from_schema( 'chicken,coleslaw', $schema ) );
     112    }
    89113}
Note: See TracChangeset for help on using the changeset viewer.