Make WordPress Core


Ignore:
Timestamp:
11/03/2016 01:45:48 AM (8 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-validation.php

    r39048 r39104  
    116116        $this->assertWPError( rest_validate_value_from_schema( 'lol', $schema ) );
    117117    }
     118
     119    public function test_type_array_with_enum() {
     120        $schema = array(
     121            'type'  => 'array',
     122            'items' => array(
     123                'enum' => array( 'chicken', 'ribs', 'brisket' ),
     124                'type' => 'string',
     125            ),
     126        );
     127        $this->assertTrue( rest_validate_value_from_schema( array( 'ribs', 'brisket' ), $schema ) );
     128        $this->assertWPError( rest_validate_value_from_schema( array( 'coleslaw' ), $schema ) );
     129    }
     130
     131    public function test_type_array_with_enum_as_csv() {
     132        $schema = array(
     133            'type'  => 'array',
     134            'items' => array(
     135                'enum' => array( 'chicken', 'ribs', 'brisket' ),
     136                'type' => 'string',
     137            ),
     138        );
     139        $this->assertTrue( rest_validate_value_from_schema( 'ribs,chicken', $schema ) );
     140        $this->assertWPError( rest_validate_value_from_schema( 'chicken,coleslaw', $schema ) );
     141    }
    118142}
Note: See TracChangeset for help on using the changeset viewer.