public function test_it_returns_the_next_uri()
 {
     $uri = Authentication::BASE_URI . '/v1/me';
     $pagedList = new PagedList(array(new User()), $uri);
     $this->assertTrue($pagedList->hasNext());
     $this->assertSame($uri, $pagedList->getNextUrl());
     $pagedList = new PagedList(array(new User()));
     $this->assertFalse($pagedList->hasNext());
 }
Beispiel #2
0
 /**
  * Get the next items for a paged list.
  *
  * @param PagedList $pagedList
  *
  * @return Response
  */
 public function getNextItems(PagedList $pagedList)
 {
     if (!$pagedList->hasNext()) {
         throw new InvalidArgumentException('The list has no more items');
     }
     $items = $pagedList->items();
     if (empty($items)) {
         throw new InvalidArgumentException('Unable to detect object type because the list contains no items');
     }
     $item = reset($items);
     $objectClassName = get_class($item);
     $objectInstance = new $objectClassName();
     $request = $this->buildRequestForPagedList($pagedList);
     return $this->execute($request, function (Response $response) use($objectInstance) {
         $mapper = new Mapper($objectInstance);
         return $mapper->toList($response);
     });
 }