Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: replace type in Pager #6596

Merged
merged 5 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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