public function testApplyToCollectionEmptyRequest()
 {
     /** @var ObjectProphecy|Request $requestMock */
     $requestMock = $this->prophesize('Symfony\\Component\\HttpFoundation\\Request');
     /* @see PaginationExtension::applyToCollection */
     $this->requestStackMock->getCurrentRequest()->willReturn($requestMock->reveal())->shouldBeCalledTimes(1);
     /* @see PaginationExtension::isPaginationEnabled */
     $this->resourceMock->getEnablePaginationParameter()->willReturn('enablePagination')->shouldBeCalledTimes(1);
     $requestMock->get('enablePagination')->shouldBeCalledTimes(1);
     $this->resourceMock->isClientAllowedToEnablePagination()->willReturn(true)->shouldBeCalledTimes(1);
     $this->resourceMock->isPaginationEnabledByDefault()->willReturn(true)->shouldBeCalledTimes(1);
     /* @see PaginationExtension::getItemsPerPage */
     $this->resourceMock->isClientAllowedToChangeItemsPerPage()->willReturn(true)->shouldBeCalledTimes(1);
     $this->resourceMock->getItemsPerPageParameter()->willReturn('itemsPerPage')->shouldBeCalledTimes(1);
     $requestMock->get('itemsPerPage')->shouldBeCalledTimes(1);
     $this->resourceMock->getItemsPerPageByDefault()->willReturn(15)->shouldBeCalledTimes(1);
     /* @see PaginationExtension::getPage */
     $this->resourceMock->getPageParameter()->willReturn('page')->shouldBeCalledTimes(1);
     $requestMock->get('page', 1)->willReturn(1)->shouldBeCalledTimes(1);
     /* @see PaginationExtension::applyToCollection */
     $this->queryBuilderMock->setFirstResult(0)->willReturn($this->queryBuilderMock->reveal())->shouldBeCalledTimes(1);
     $this->queryBuilderMock->setMaxResults(15)->willReturn($this->queryBuilderMock->reveal())->shouldBeCalledTimes(1);
     $extension = new PaginationExtension($this->managerRegistryMock->reveal(), $this->requestStackMock->reveal());
     $extension->applyToCollection($this->resourceMock->reveal(), $this->queryBuilderMock->reveal());
 }
 /**
  * Gets the number of items per page to display.
  *
  * @param ResourceInterface $resource
  * @param Request           $request
  *
  * @return float
  */
 private function getItemsPerPage(ResourceInterface $resource, Request $request)
 {
     if ($resource->isClientAllowedToChangeItemsPerPage() && ($itemsPerPage = $request->get($resource->getItemsPerPageParameter()))) {
         return (double) $itemsPerPage;
     }
     return $resource->getItemsPerPageByDefault();
 }