- Timestamp:
- 11/03/2016 02:17:39 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-users-controller.php
r39096 r39105 364 364 } 365 365 366 public function test_get_items_invalid_order() { 367 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 368 $request->set_param( 'order', 'asc,id' ); 369 $response = $this->server->dispatch( $request ); 370 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 371 } 372 373 public function test_get_items_invalid_orderby() { 374 $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); 375 $request->set_param( 'orderby', 'invalid' ); 376 $response = $this->server->dispatch( $request ); 377 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 378 } 379 366 380 public function test_get_items_offset() { 367 381 wp_set_current_user( self::$user ); … … 380 394 $response = $this->server->dispatch( $request ); 381 395 $this->assertCount( 2, $response->get_data() ); 396 // 'offset' invalid value should error 397 $request->set_param( 'offset', 'moreplease' ); 398 $response = $this->server->dispatch( $request ); 399 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 382 400 } 383 401 … … 400 418 $this->assertEquals( 2, count( $data ) ); 401 419 $this->assertEquals( $id3, $data[0]['id'] ); 420 // Invalid include should fail 421 $request->set_param( 'include', 'invalid' ); 422 $response = $this->server->dispatch( $request ); 423 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 402 424 // No privileges 425 $request->set_param( 'include', array( $id3, $id1 ) ); 403 426 wp_set_current_user( 0 ); 404 427 $response = $this->server->dispatch( $request ); … … 422 445 $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) ); 423 446 $this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) ); 447 // Invalid exlude value should error. 448 $request->set_param( 'exclude', 'none-of-those-please' ); 449 $response = $this->server->dispatch( $request ); 450 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 424 451 } 425 452
Note: See TracChangeset
for help on using the changeset viewer.