From 8b86db76d69f8e82a4633159ed2a49239009b06f Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo <1102197+priyadi@users.noreply.github.com> Date: Sun, 16 Jun 2024 23:17:54 +0700 Subject: [PATCH] test: add `UnsupportedCollectionTest` (#77) --- CHANGELOG.md | 4 ++ .../UnitTests/UnsupportedCollectionTest.php | 50 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/src/UnitTests/UnsupportedCollectionTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 40689f1..43276a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +# 0.11.1 + +* test: add `UnsupportedCollectionTest` + # 0.11.0 * refactor: change `PageableInterface::getPageIdentifierClass()` from static to diff --git a/tests/src/UnitTests/UnsupportedCollectionTest.php b/tests/src/UnitTests/UnsupportedCollectionTest.php new file mode 100644 index 0000000..b493531 --- /dev/null +++ b/tests/src/UnitTests/UnsupportedCollectionTest.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE file + * that was distributed with this source code. + */ + +namespace Rekalogika\Rekapager\Tests\UnitTests; + +use Doctrine\Common\Collections\ArrayCollection; +use PHPUnit\Framework\Attributes\RequiresPhp; +use PHPUnit\Framework\TestCase; +use Rekalogika\Rekapager\Doctrine\Collections\SelectableAdapter; +use Rekalogika\Rekapager\Keyset\KeysetPageable; +use Rekalogika\Rekapager\Offset\OffsetPageable; + +class UnsupportedCollectionTest extends TestCase +{ + /** + * @todo Fix after the resolution of https://github.com/doctrine/collections/pull/421 + */ + #[RequiresPhp('99999')] + public function testCollectionOfScalarWithKeysetPagination(): void + { + $collection = new ArrayCollection([1, 2, 3, 4, 5]); + $adapter = new SelectableAdapter($collection); + $pageable = new KeysetPageable($adapter, 2); + + foreach ($pageable->getFirstPage() as $item); + } + + /** + * @todo Fix after the resolution of https://github.com/doctrine/collections/pull/421 + */ + #[RequiresPhp('99999')] + public function testCollectionOfScalarWithOffsetPagination(): void + { + $collection = new ArrayCollection([1, 2, 3, 4, 5]); + $adapter = new SelectableAdapter($collection); + $pageable = new OffsetPageable($adapter, 2); + + foreach ($pageable->getFirstPage() as $item); + } +}