Skip to content

Commit

Permalink
Merge pull request #6596 from ddevsr/docs-pager
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner authored Sep 28, 2022
2 parents 8a93b65 + 23be5bf commit c89ba56
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions system/Pager/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function store(string $group, int $page, ?int $perPage, int $total, int $
/**
* Sets segment for a group.
*
* @return mixed
* @return $this
*/
public function setSegment(int $number, string $group = 'default')
{
Expand All @@ -174,7 +174,7 @@ public function setSegment(int $number, string $group = 'default')
/**
* Sets the path that an aliased group of links will use.
*
* @return mixed
* @return $this
*/
public function setPath(string $path, string $group = 'default')
{
Expand Down
4 changes: 2 additions & 2 deletions system/Pager/PagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public function makeLinks(int $page, int $perPage, int $total, string $template
* Stores a set of pagination data for later display. Most commonly used
* by the model to automate the process.
*
* @return mixed
* @return $this
*/
public function store(string $group, int $page, int $perPage, int $total);

/**
* Sets the path that an aliased group of links will use.
*
* @return mixed
* @return $this
*/
public function setPath(string $path, string $group = 'default');

Expand Down
21 changes: 15 additions & 6 deletions tests/system/Pager/PagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use CodeIgniter\Pager\Exceptions\PagerException;
use CodeIgniter\Test\CIUnitTestCase;
use Config\App;
use Config\Pager;
use Config\Pager as PagerConfig;
use Config\Services;

/**
Expand All @@ -28,7 +28,7 @@
*/
final class PagerTest extends CIUnitTestCase
{
private ?\CodeIgniter\Pager\Pager $pager = null;
private ?Pager $pager = null;
private $config;

protected function setUp(): void
Expand Down Expand Up @@ -58,8 +58,8 @@ private function createPager(string $requestUri): void
$request = $request->withMethod('GET');
Services::injectMock('request', $request);

$this->config = new Pager();
$this->pager = new \CodeIgniter\Pager\Pager($this->config, Services::renderer());
$this->config = new PagerConfig();
$this->pager = new Pager($this->config, Services::renderer());
}

public function testSetPathRemembersPath()
Expand Down Expand Up @@ -180,6 +180,15 @@ public function testStoreWithSegments()
);
}

public function testGetPageURIWithURIReturnObject()
{
$this->pager->store('bar', 5, 25, 100, 1);

$uri = $this->pager->getPageURI(7, 'bar', true);

$this->assertInstanceOf(URI::class, $uri);
}

public function testHasMoreDefaultsToFalse()
{
$this->assertFalse($this->pager->hasMore('foo'));
Expand Down Expand Up @@ -463,8 +472,8 @@ public function testBasedURI()

Services::injectMock('request', $request);

$this->config = new Pager();
$this->pager = new \CodeIgniter\Pager\Pager($this->config, Services::renderer());
$this->config = new PagerConfig();
$this->pager = new Pager($this->config, Services::renderer());

$_GET['page_foo'] = 2;

Expand Down

0 comments on commit c89ba56

Please sign in to comment.