/** * @test */ public function testCreatePagingLinks() { $pathToLinkMapping = [[$this->createPageLink(1), self::DUMMY_SERVER . $this->createPageLink(1)], [$this->createPageLink(6), self::DUMMY_SERVER . $this->createPageLink(6)], [$this->createPageLink(4), self::DUMMY_SERVER . $this->createPageLink(4)], [$this->createPageLink(2), self::DUMMY_SERVER . $this->createPageLink(2)]]; $this->pagingInfo->expects($this->once())->method('getPagingConfig')->will($this->returnValue($this->pagingProperties)); $this->pagingProvider->expects($this->once())->method('getContext')->will($this->returnValue($this->pagingContext)); $this->pagingContext->expects($this->once())->method('getQuery')->will($this->returnValue($this->getStubQueryParams())); $this->pagingProperties->expects($this->atLeastOnce())->method('toArray')->will($this->returnValue($this->getStubPagingConfig())); $this->pagingProperties->expects($this->once())->method('getLimit')->will($this->returnValue(25)); $this->pagingContext->expects($this->once())->method('getPathInfo')->will($this->returnValue(self::DUMMY_PATHINFO)); $this->pagingContext->expects($this->atLeastOnce())->method('getUriForPath')->will($this->returnValueMap($pathToLinkMapping)); $this->pagingInfo->expects($this->once())->method('getFirstPage')->will($this->returnValue(1)); $this->pagingInfo->expects($this->once())->method('getLastPage')->will($this->returnValue(6)); $this->pagingInfo->expects($this->once())->method('getNextPage')->will($this->returnValue(4)); $this->pagingInfo->expects($this->once())->method('getPreviousPage')->will($this->returnValue(2)); $actualLinks = $this->apiPagingServiceImpl->createPagingLinks($this->pagingInfo); $expectedLinks = $this->getLinksString($pathToLinkMapping); $this->assertEquals($expectedLinks, $actualLinks); }
/** * @param ApiPagingService $service * @param PagingInfo $info */ protected function populatePagingHeaders(ApiPagingService $service, PagingInfo $info) { $links = $service->createPagingLinks($info); $service->populatePagingHeaders($info, $links); }