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

Commit

Permalink
Failing test case for #2309
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber committed Feb 24, 2016
1 parent 1af67d9 commit cb94a9d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test-rest-categories-controller.php
Expand Up @@ -489,6 +489,31 @@ public function test_get_terms_pagination_headers() {
$this->assertFalse( stripos( $headers['Link'], 'rel="next"' ) );
}

public function test_get_items_per_page_exceeds_number_of_items() {
// Start of the index + Uncategorized default term
for ( $i = 0; $i < 17; $i++ ) {
$this->factory->category->create( array(
'name' => "Category {$i}",
) );
}
$request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
$request->set_param( 'page', 1 );
$request->set_param( 'per_page', 100 );
$response = $this->server->dispatch( $request );
$headers = $response->get_headers();
$this->assertEquals( 18, $headers['X-WP-Total'] );
$this->assertEquals( 1, $headers['X-WP-TotalPages'] );
$this->assertCount( 18, $response->get_data() );
$request = new WP_REST_Request( 'GET', '/wp/v2/categories' );
$request->set_param( 'page', 2 );
$request->set_param( 'per_page', 100 );
$response = $this->server->dispatch( $request );
$headers = $response->get_headers();
$this->assertEquals( 18, $headers['X-WP-Total'] );
$this->assertEquals( 1, $headers['X-WP-TotalPages'] );
$this->assertCount( 0, $response->get_data() );
}

public function test_get_item() {
$request = new WP_REST_Request( 'GET', '/wp/v2/categories/1' );
$response = $this->server->dispatch( $request );
Expand Down

0 comments on commit cb94a9d

Please sign in to comment.