Skip to content

Commit

Permalink
Test coverage 100% (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored Sep 25, 2024
1 parent 41f2c3a commit 16f1415
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
9 changes: 9 additions & 0 deletions tests/Paginator/KeysetPaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ public function testDataReaderWithoutSortableInterface(): void
new KeysetPaginator($this->getNonSortableDataReader());
}

public function testDataReaderWithLimit(): void
{
$dataReader = (new IterableDataReader([]))->withLimit(1);

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Limited data readers are not supported by keyset pagination.');
new KeysetPaginator($dataReader);
}

public function testDataReaderWithoutLimitableInterface(): void
{
$dataReader = new class () implements ReadableDataInterface, SortableDataInterface, FilterableDataInterface {
Expand Down
21 changes: 13 additions & 8 deletions tests/Reader/Iterable/IterableDataReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,15 @@ public function testOffsetIsApplied(): void
$data = $reader->read();

$this->assertCount(3, $data);
$this->assertSame([
2 => self::ITEM_3,
3 => self::ITEM_4,
4 => self::ITEM_5,
], $data);
$this->assertSame(
[
2 => self::ITEM_3,
3 => self::ITEM_4,
4 => self::ITEM_5,
],
$data
);
$this->assertSame(2, $reader->getOffset());
}

public function testAscSorting(): void
Expand Down Expand Up @@ -396,14 +400,15 @@ public function testGeneratorAsDataSet(): void

public function testCustomFilter(): void
{
$filter = new All(new GreaterThan('id', 0), new Digital('name'));
$reader = (new IterableDataReader(self::DEFAULT_DATASET))
->withAddedFilterHandlers(new DigitalHandler())
->withFilter(
new All(new GreaterThan('id', 0), new Digital('name'))
);
->withFilter($filter);

$filtered = $reader->read();

$this->assertSame([4 => self::ITEM_5], $filtered);
$this->assertSame($filter, $reader->getFilter());
}

public function testCustomEqualsProcessor(): void
Expand Down

0 comments on commit 16f1415

Please sign in to comment.