示例#1
0
 /**
  * Get a new paginator instance.
  *
  * @param array $items
  * @param integer $total
  * @param integer $perPage
  * @return \DeSmart\Pagination\Paginator
  */
 public function make(array $items, $total, $perPage = null)
 {
     $paginator = new Paginator($this, $items, $total, $perPage);
     $paginator->setUrlGenerator($this->urlGenerator);
     $paginator->setRouter($this->router);
     return $paginator->setupPaginationContext();
 }
示例#2
0
 public function testCanAddFragmentWithRouteConfig()
 {
     $generator = m::mock('Illuminate\\Routing\\UrlGenerator');
     $p = new Paginator($env = m::mock('DeSmart\\Pagination\\Factory'), array('foo', 'bar', 'baz'), 3, 2);
     $p->fragment('test');
     $p->setUrlGenerator($generator);
     $p->withoutQuery();
     $env->shouldReceive('getRequest')->never();
     $env->shouldReceive('getPageName')->andReturn('page');
     $generator->shouldReceive('route')->once()->with($name = 'test.route', array('page' => 1), true, null);
     $p->route($name);
     $this->assertEquals('#test', $p->getUrl(1));
 }