Skip to content

Commit

Permalink
[#87] Added unit test for page_size param
Browse files Browse the repository at this point in the history
- Added test showing that page size parameter can be passed, and will be
  honored.
  • Loading branch information
weierophinney committed Jul 23, 2013
1 parent 55a8f99 commit 53d31d7
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/PhlyRestfullyTest/ResourceControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,33 @@ public function testReturnsHalCollectionForPaginatedList()
$this->assertEquals(1, $result->pageSize);
}

public function testReturnsHalCollectionForPaginatedListUsingPassedPageSizeParameter()
{
$items = array(
array('id' => 'foo', 'bar' => 'baz'),
array('id' => 'bar', 'bar' => 'baz'),
array('id' => 'baz', 'bar' => 'baz'),
);
$adapter = new ArrayPaginator($items);
$paginator = new Paginator($adapter);
$this->resource->getEventManager()->attach('fetchAll', function ($e) use ($paginator) {
return $paginator;
});

$this->controller->setPageSizeParam('page_size');
$request = $this->controller->getRequest();
$request->setQuery(new Parameters(array(
'page' => 2,
'page_size' => 1,
)));

$result = $this->controller->getList();
$this->assertInstanceOf('PhlyRestfully\HalCollection', $result);
$this->assertSame($paginator, $result->collection);
$this->assertEquals(2, $result->page);
$this->assertEquals(1, $result->pageSize);
}

/**
* @depends testReturnsHalCollectionForNonPaginatedList
*/
Expand Down

0 comments on commit 53d31d7

Please sign in to comment.