Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Added test for omitFirstPage param
Browse files Browse the repository at this point in the history
  • Loading branch information
bobvandevijver committed Mar 15, 2016
1 parent c5bd1dc commit b3226be
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public function viewWithOptionsAction()
return $this->renderPagerfanta('viewWithOptions');
}

public function viewWithFirstPageParamAction(Request $request)
{
return $this->defaultWithRequestAction($request, 'viewWithFirstPageParam');
}

public function defaultTranslatedViewAction()
{
return $this->renderPagerfanta('defaultTranslatedView');
Expand All @@ -54,9 +59,9 @@ public function viewWithRouteParamsAction($test = null)
return $this->renderPagerfanta('viewWithRouteParams');
}

public function defaultWithRequestAction(Request $request)
public function defaultWithRequestAction(Request $request, $name = 'defaultView')
{
$template = $this->buildTemplateName('defaultView');
$template = $this->buildTemplateName($name);
$pagerfanta = $this->createPagerfanta();
$pagerfanta->setMaxPerPage($request->query->get('maxPerPage', 10));
$pagerfanta->setCurrentPage($request->query->get('currentPage', 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ pagerfanta_my_view_1:
pagerfanta_correct_view:
path: /pagerfanta/custom-page
defaults: { _controller: WhiteOctoberPagerfantaTestBundle:Pagerfanta:defaultWithRequest }

pagerfanta_view_with_first_page_param:
path: /pagerfanta/view-with-first-page-param
defaults: { _controller: WhiteOctoberPagerfantaTestBundle:Pagerfanta:viewWithFirstPageParam }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ pagerfanta(pagerfanta, 'default', {'omitFirstPage': false}) }}
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,27 @@ public function testFirstPageLinkDoesNotHaveParam()
);
}

/**
* @test
*/
public function testFirstPageParam()
{
$this->assertView('view-with-first-page-param?currentPage=2', <<<EOF
<nav>
<a href="/pagerfanta/view-with-first-page-param?currentPage=2&page=1">Previous</a>
<a href="/pagerfanta/view-with-first-page-param?currentPage=2&page=1">1</a>
<span class="current">2</span>
<a href="/pagerfanta/view-with-first-page-param?currentPage=2&page=3">3</a>
<a href="/pagerfanta/view-with-first-page-param?currentPage=2&page=4">4</a>
<a href="/pagerfanta/view-with-first-page-param?currentPage=2&page=5">5</a>
<span class="dots">...</span>
<a href="/pagerfanta/view-with-first-page-param?currentPage=2&page=10">10</a>
<a href="/pagerfanta/view-with-first-page-param?currentPage=2&page=3">Next</a>
</nav>
EOF
);
}

/**
* @test
*/
Expand Down

0 comments on commit b3226be

Please sign in to comment.