8000 Failing test case for #2309 · WP-API/WP-API@cb94a9d · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Commit cb94a9d

Browse files
Failing test case for #2309
1 parent 1af67d9 commit cb94a9d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test-rest-categories-controller.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,31 @@ public function test_get_terms_pagination_headers() {
489489
$this->assertFalse( stripos( $headers['Link'], 'rel="next"' ) );
490490
}
491491

492+
public function test_get_items_per_page_exceeds_number_of_items() {
493+
// Start of the index + Uncategorized default term
494+
for ( $i = 0; $i < 17; $i++ ) {
495+
$this->factory->category->create( array(
496+
'name' => "Category {$i}",
497+
) );
498+
}
499+
$request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
500+
$request->set_param( 'page', 1 );
501+
$request->set_param( 'per_page', 100 );
502+
$response = $this->server->dispatch( $request );
503+
$headers = $response->get_headers();
504+
$this->assertEquals( 18, $headers['X-WP-Total'] );
505+
$this->assertEquals( 1, $headers['X-WP-TotalPages'] );
506+
$this->assertCount( 18, $response->get_data() );
507+
$request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
508+
$request->set_param( 'page', 2 );
509+
$request->set_param( 'per_page', 100 );
510+
$response = $this->server->dispatch( $request );
511+
$headers = $response->get_headers();
512+
$this->assertEquals( 18, $headers['X-WP-Total'] );
513+
$this->assertEquals( 1, $headers['X-WP-TotalPages'] );
514+
$this->assertCount( 0, $response->get_data() );
515+
}
516+
492517
public function test_get_item() {
493518
$request = new WP_REST_Request( 'GET', '/wp/v2/categories/1' );
494519
$response = $this->server->dispatch( $request );

0 commit comments

Comments
 (0)
0