-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for zero proximity pager, empty pager, and test curre…
…nt count for all pagers (#12)
- Loading branch information
Showing
10 changed files
with
513 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of rekalogika/rekapager package. | ||
* | ||
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
namespace Rekalogika\Rekapager\Tests\IntegrationTests\Pager; | ||
|
||
use PHPUnit\Framework\Attributes\DataProviderExternal; | ||
use Rekalogika\Rekapager\Tests\IntegrationTests\DataProvider\PageableGeneratorProvider; | ||
|
||
class EmptyPagerTest extends PagerTestCase | ||
{ | ||
protected function getSetName(): string | ||
{ | ||
return 'empty'; | ||
} | ||
|
||
#[DataProviderExternal(PageableGeneratorProvider::class, 'all')] | ||
public function testFirstPage(string $pageableGeneratorClass): void | ||
{ | ||
$pageable = $this->createPageableFromGenerator($pageableGeneratorClass); | ||
$pager = $this->createPagerFromPageable($pageable); | ||
|
||
$this->assertPager( | ||
$pager, | ||
proximity: 2, | ||
hasPrevious: false, | ||
hasNext: false, | ||
hasFirst: false, | ||
hasLast: false, | ||
hasGapToFirstPage: false, | ||
hasGapToLastPage: false, | ||
numOfPreviousNeighboringPages: 0, | ||
numOfNextNeighboringPages: 0, | ||
firstPageNumber: null, | ||
lastPageNumber: null, | ||
currentPageNumber: 1, | ||
previousPageNumbers: [], | ||
nextPageNumbers: [], | ||
currentCount: 0, | ||
); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
tests/src/IntegrationTests/Pager/EmptyZeroProximityPagerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of rekalogika/rekapager package. | ||
* | ||
* (c) Priyadi Iman Nurcahyo <https://rekalogika.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE file | ||
* that was distributed with this source code. | ||
*/ | ||
|
||
namespace Rekalogika\Rekapager\Tests\IntegrationTests\Pager; | ||
|
||
use PHPUnit\Framework\Attributes\DataProviderExternal; | ||
use Rekalogika\Rekapager\Tests\IntegrationTests\DataProvider\PageableGeneratorProvider; | ||
|
||
class EmptyZeroProximityPagerTest extends PagerTestCase | ||
{ | ||
protected function getSetName(): string | ||
{ | ||
return 'empty'; | ||
} | ||
|
||
protected function getProximity(): int | ||
{ | ||
return 0; | ||
} | ||
|
||
#[DataProviderExternal(PageableGeneratorProvider::class, 'all')] | ||
public function testFirstPage(string $pageableGeneratorClass): void | ||
{ | ||
$pageable = $this->createPageableFromGenerator($pageableGeneratorClass); | ||
$pager = $this->createPagerFromPageable($pageable); | ||
|
||
$this->assertPager( | ||
$pager, | ||
proximity: 0, | ||
hasPrevious: false, | ||
hasNext: false, | ||
hasFirst: false, | ||
hasLast: false, | ||
hasGapToFirstPage: false, | ||
hasGapToLastPage: false, | ||
numOfPreviousNeighboringPages: 0, | ||
numOfNextNeighboringPages: 0, | ||
firstPageNumber: null, | ||
lastPageNumber: null, | ||
currentPageNumber: 1, | ||
previousPageNumbers: [], | ||
nextPageNumbers: [], | ||
currentCount: 0, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.