|
@@ 311-327 (lines=17) @@
|
| 308 |
|
$this->assertEquals('Apple', $data[0]['title']['rendered']); |
| 309 |
|
} |
| 310 |
|
|
| 311 |
|
public function test_get_items_multiple_slugs_array_query() |
| 312 |
|
{ |
| 313 |
|
$this->factory->post->create(array( 'post_title' => 'Apple', 'post_status' => 'publish' )); |
| 314 |
|
$this->factory->post->create(array( 'post_title' => 'Banana', 'post_status' => 'publish' )); |
| 315 |
|
$this->factory->post->create(array( 'post_title' => 'Peach', 'post_status' => 'publish' )); |
| 316 |
|
$request = new WP_REST_Request('GET', '/wp/v2/posts'); |
| 317 |
|
$request->set_param('slug', array( 'banana', 'peach' )); |
| 318 |
|
$response = $this->server->dispatch($request); |
| 319 |
|
$this->assertEquals(200, $response->get_status()); |
| 320 |
|
$data = $response->get_data(); |
| 321 |
|
$this->assertEquals(2, count($data)); |
| 322 |
|
$titles = array( |
| 323 |
|
$data[0]['title']['rendered'], |
| 324 |
|
$data[1]['title']['rendered'], |
| 325 |
|
); |
| 326 |
|
sort($titles); |
| 327 |
|
$this->assertEquals(array( 'Banana', 'Peach' ), $titles); |
| 328 |
|
} |
| 329 |
|
|
| 330 |
|
public function test_get_items_multiple_slugs_string_query() |
|
@@ 330-346 (lines=17) @@
|
| 327 |
|
$this->assertEquals(array( 'Banana', 'Peach' ), $titles); |
| 328 |
|
} |
| 329 |
|
|
| 330 |
|
public function test_get_items_multiple_slugs_string_query() |
| 331 |
|
{ |
| 332 |
|
$this->factory->post->create(array( 'post_title' => 'Apple', 'post_status' => 'publish' )); |
| 333 |
|
$this->factory->post->create(array( 'post_title' => 'Banana', 'post_status' => 'publish' )); |
| 334 |
|
$this->factory->post->create(array( 'post_title' => 'Peach', 'post_status' => 'publish' )); |
| 335 |
|
$request = new WP_REST_Request('GET', '/wp/v2/posts'); |
| 336 |
|
$request->set_param('slug', 'apple,banana'); |
| 337 |
|
$response = $this->server->dispatch($request); |
| 338 |
|
$this->assertEquals(200, $response->get_status()); |
| 339 |
|
$data = $response->get_data(); |
| 340 |
|
$this->assertEquals(2, count($data)); |
| 341 |
|
$titles = array( |
| 342 |
|
$data[0]['title']['rendered'], |
| 343 |
|
$data[1]['title']['rendered'], |
| 344 |
|
); |
| 345 |
|
sort($titles); |
| 346 |
|
$this->assertEquals(array( 'Apple', 'Banana' ), $titles); |
| 347 |
|
} |
| 348 |
|
|
| 349 |
|
public function test_get_items_status_query() |