Make WordPress Core


Ignore:
Timestamp:
11/03/2016 02:17:39 AM (8 years ago)
Author:
rachelbaker
Message:

REST API: Clean-up our validation callbacks and add missing array items properties in our endpoint schemas.

Props joehoyle, jnylen0.
Fixes #38617.

File:
1 edited

Legend:

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

    r39047 r39105  
    9696        $this->assertEquals( 1, count( $data ) );
    9797        $this->assertEquals( $id2, $data[0]['id'] );
     98        // Invalid parent should fail
     99        $request->set_param( 'parent', 'some-slug' );
     100        $response = $this->server->dispatch( $request );
     101        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    98102    }
    99103
     
    130134        $this->assertEquals( 1, count( $data ) );
    131135        $this->assertEquals( $id1, $data[0]['id'] );
     136        // Invalid parent_exclude should error
     137        $request->set_param( 'parent_exclude', 'some-slug' );
     138        $response = $this->server->dispatch( $request );
     139        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    132140    }
    133141
     
    157165        $this->assertEquals( $id2, $data[2]['id'] );
    158166        $this->assertEquals( $id3, $data[3]['id'] );
     167        // Invalid menu_order should fail
     168        $request = new WP_REST_Request( 'GET', '/wp/v2/pages' );
     169        $request->set_param( 'menu_order', 'top-first' );
     170        $response = $this->server->dispatch( $request );
     171        $this->assertErrorResponse( 'rest_invalid_param', $response, 400 );
    159172    }
    160173
Note: See TracChangeset for help on using the changeset viewer.