- 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-tags-controller.php
r38974 r39105 99 99 $this->assertEquals( 'Season 5', $data[0]['name'] ); 100 100 $this->assertEquals( 'The Be Sharps', $data[1]['name'] ); 101 // invalid value should fail 102 $request->set_param( 'hide_empty', 'nothanks' ); 103 $response = $this->server->dispatch( $request ); 104 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 101 105 } 102 106 … … 118 122 $this->assertEquals( 2, count( $data ) ); 119 123 $this->assertEquals( $id3, $data[0]['id'] ); 124 // Include invalid value shoud fail 125 $request->set_param( 'include', array( 'myterm' ) ); 126 $response = $this->server->dispatch( $request ); 127 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 120 128 } 121 129 … … 133 141 $this->assertTrue( in_array( $id1, wp_list_pluck( $data, 'id' ), true ) ); 134 142 $this->assertFalse( in_array( $id2, wp_list_pluck( $data, 'id' ), true ) ); 143 // Invalid exclude value should fail 144 $request->set_param( 'exclude', array( 'invalid' ) ); 145 $response = $this->server->dispatch( $request ); 146 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 135 147 } 136 148 … … 152 164 $response = $this->server->dispatch( $request ); 153 165 $this->assertCount( 2, $response->get_data() ); 166 // 'offset' invalid value shoudl fail 167 $request->set_param( 'offset', 'moreplease' ); 168 $response = $this->server->dispatch( $request ); 169 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 154 170 } 155 171 … … 182 198 $this->assertEquals( 2, count( $data ) ); 183 199 $this->assertEquals( 'Apple', $data[0]['name'] ); 200 // Invalid orderby should fail. 201 $request->set_param( 'orderby', 'invalid' ); 202 $response = $this->server->dispatch( $request ); 203 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 184 204 } 185 205 … … 232 252 $this->assertEquals( 2, count( $data ) ); 233 253 $this->assertEquals( 'DC', $data[0]['name'] ); 254 255 // Invalid post should error. 256 $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); 257 $request->set_param( 'post', 'invalid-post' ); 258 $response = $this->server->dispatch( $request ); 259 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 234 260 } 235 261
Note: See TracChangeset
for help on using the changeset viewer.