- 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-posts-controller.php
r39104 r39105 93 93 'before', 94 94 'categories', 95 'categories_exclude', 95 96 'context', 96 97 'exclude', … … 106 107 'sticky', 107 108 'tags', 109 'tags_exclude', 108 110 ), $keys ); 109 111 } … … 184 186 $this->assertNotEquals( self::$editor_id, $data[0]['author'] ); 185 187 $this->assertNotEquals( self::$editor_id, $data[1]['author'] ); 188 // invalid author_exclude errors 189 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); 190 $request->set_param( 'author_exclude', 'invalid' ); 191 $response = $this->server->dispatch( $request ); 192 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 186 193 } 187 194 … … 203 210 $this->assertEquals( 2, count( $data ) ); 204 211 $this->assertEquals( $id1, $data[0]['id'] ); 212 // Invalid include should error 213 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); 214 $request->set_param( 'include', 'invalid' ); 215 $response = $this->server->dispatch( $request ); 216 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 205 217 } 206 218 … … 225 237 $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) ); 226 238 $this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) ); 239 240 $request->set_param( 'exclude', 'invalid' ); 241 $response = $this->server->dispatch( $request ); 242 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 227 243 } 228 244 … … 407 423 $data = $response->get_data(); 408 424 $this->assertEquals( 'Apple Cobbler', $data[0]['title']['rendered'] ); 425 // order=>asc,id should fail 426 $request->set_param( 'order', 'asc,id' ); 427 $response = $this->server->dispatch( $request ); 428 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 429 // orderby=>content should fail (invalid param test) 430 $request->set_param( 'order', 'asc' ); 431 $request->set_param( 'orderby', 'content' ); 432 $response = $this->server->dispatch( $request ); 433 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 409 434 } 410 435 … … 457 482 $response = $this->server->dispatch( $request ); 458 483 $this->assertCount( 2, $response->get_data() ); 484 // Invalid 'offset' should error 485 $request->set_param( 'offset', 'moreplease' ); 486 $response = $this->server->dispatch( $request ); 487 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 459 488 } 460 489 … … 513 542 $response = $this->server->dispatch( $request ); 514 543 $this->assertCount( 1, $response->get_data() ); 544 545 $request->set_param( 'tags', array( 'my-tag' ) ); 546 $response = $this->server->dispatch( $request ); 547 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 515 548 } 516 549 … … 535 568 $this->assertCount( 1, $data ); 536 569 $this->assertEquals( $id2, $data[0]['id'] ); 570 571 $request->set_param( 'tags_exclude', array( 'my-tag' ) ); 572 $response = $this->server->dispatch( $request ); 573 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 537 574 } 538 575 … … 552 589 $post = $posts[0]; 553 590 $this->assertEquals( $id2, $post['id'] ); 591 592 $request->set_param( 'sticky', 'nothanks' ); 593 $response = $this->server->dispatch( $request ); 594 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 554 595 } 555 596 … … 1990 2031 $data = $response->get_data(); 1991 2032 $properties = $data['schema']['properties']; 1992 $this->assertEquals( 2 5, count( $properties ) );2033 $this->assertEquals( 23, count( $properties ) ); 1993 2034 $this->assertArrayHasKey( 'author', $properties ); 1994 2035 $this->assertArrayHasKey( 'comment_status', $properties ); … … 2013 2054 $this->assertArrayHasKey( 'type', $properties ); 2014 2055 $this->assertArrayHasKey( 'tags', $properties ); 2015 $this->assertArrayHasKey( 'tags_exclude', $properties );2016 2056 $this->assertArrayHasKey( 'categories', $properties ); 2017 $this->assertArrayHasKey( 'categories_exclude', $properties );2018 2057 } 2019 2058
Note: See TracChangeset
for help on using the changeset viewer.